1; GEOS KERNAL by Berkeley Softworks 2; reverse engineered by Maciej Witkowiak, Michael Steil 3; 4; Graphics library: GraphicsString 5 6.include "const.inc" 7.include "geossym.inc" 8.include "geosmac.inc" 9.include "config.inc" 10.include "gkernal.inc" 11.include "c64.inc" 12 13.import _PutString 14.import _SetPattern 15.import GraphPenX 16.import GraphPenY 17.import __GrStSetCoords 18.import _DrawLine 19.import _Rectangle 20.import _FrameRectangle 21.import CallRoutine 22 23GraphPenXL = GraphPenX 24GraphPenXH = GraphPenX+1 25 26.global _GraphicsString 27.global GetCoords 28.global GetR0AndInc 29 30.segment "graph2k" 31 32;--------------------------------------------------------------- 33; GraphicsString $C136 34; 35; Pass: r0 ptr to graphics string,0 36; MOVEPENTO 1 .word x, .byte y 37; LINETO 2 .word x, .byte y 38; RECTANGLETO 3 .word x, .byte y 39; NEWPATTERN 5 .byte pattern No. 40; ESC_PUTSTRING 6 see PutString 41; FRAME_RECTO 7 .word x, .byte y 42; New: 43; MOVEPENRIGHT 8 .word x 44; MOVEPENDOWN 9 .byte y 45; MOVERIGHTDOWN 10 .word x, .byte y 46; Return: graphics being drawed 47; Destroyed: a, x, y, r0 - r15 48;--------------------------------------------------------------- 49_GraphicsString: 50 jsr GetR0AndInc 51.ifdef wheels_size_and_speed 52 tay 53 beq @1 54.else 55 beq @1 56 tay 57.endif 58 dey 59 lda GStrTL,y 60 ldx GStrTH,y 61 jsr CallRoutine 62 bra _GraphicsString 63@1: rts 64 65.define GStrT _DoMovePenTo, _DoLineTo, _DoRectangleTo, _DoNothing, _DoNewPattern, _DoESC_PutString, _DoFrame_RecTo, _DoPenXDelta, _DoPenYDelta, _DoPenXYDelta 66GStrTL: 67 .lobytes GStrT 68GStrTH: 69 .hibytes GStrT 70 71_DoMovePenTo: 72 jsr GetCoords 73 sta GraphPenY 74 stx GraphPenXL 75 sty GraphPenXH 76.if .defined(bsw128) || .defined(wheels_size) 77_DoNothing: 78.endif 79 rts 80 81_DoLineTo: 82 MoveW GraphPenX, r3 83 MoveB GraphPenY, r11L 84 jsr _DoMovePenTo 85 sta r11H 86 stx r4L 87 sty r4H 88 sec 89 lda #0 90 jmp _DrawLine 91 92_DoRectangleTo: 93 jsr __GrStSetCoords 94 jmp _Rectangle 95 96.ifndef bsw128 97.ifndef wheels_size 98_DoNothing: 99 rts 100.endif 101.endif 102 103_DoNewPattern: 104 jsr GetR0AndInc 105 jmp _SetPattern 106 107_DoESC_PutString: 108 jsr GetR0AndInc 109 sta r11L 110 jsr GetR0AndInc 111 sta r11H 112 jsr GetR0AndInc 113 sta r1H 114.if .defined(bsw128) || .defined(wheels_size_and_speed) 115 jmp _PutString 116.else 117 jsr _PutString 118 rts 119.endif 120 121_DoFrame_RecTo: 122 jsr __GrStSetCoords 123 lda #$FF 124 jmp _FrameRectangle 125 126_DoPenXYDelta: 127 ldx #1 128.ifdef wheels_size 129 bra DPXD0 130.else 131 bne DPXD0 132.endif 133_DoPenXDelta: 134 ldx #0 135DPXD0: 136 ldy #0 137 lda (r0),Y 138 iny 139 add GraphPenXL 140 sta GraphPenXL 141 lda (r0),Y 142 iny 143 adc GraphPenXH 144 sta GraphPenXH 145 beqx DPYD1 146 bne DPYD0 147_DoPenYDelta: 148 ldy #0 149DPYD0: 150 lda (r0),Y 151 iny 152 add GraphPenY 153 sta GraphPenY 154 iny 155DPYD1: 156 tya 157 add r0L 158 sta r0L 159 bcc @1 160 inc r0H 161@1: rts 162 163.segment "graph2m" 164 165GetCoords: 166 jsr GetR0AndInc 167 tax 168 jsr GetR0AndInc 169 sta r2L 170 jsr GetR0AndInc 171 ldy r2L 172 rts ;x/y - x, a - y 173 174GetR0AndInc: 175 ldy #0 176 lda (r0),Y 177.ifdef wheels_size 178.global IncR0 179IncR0: 180.endif 181 inc r0L 182 bne @1 183 inc r0H 184@1: 185.ifndef wheels_size_and_speed ; only one caller needed this 186 cmp #0 187.endif 188 rts 189 190