;; ;; Final Cartridge III annotated disassembly ;; by Tadeusz Kijkowski ;; version 0.7 ;; 02 APR 2009 ;; $02 = destroyed by interrupt $8b,$8c = used by draw drop-down menu - position x $8d = used by draw drop-down menu - position x / 8 $91 = RUN/STOP flag destroyed by interrupt $92 = address of active drawing screen $94,$95 = selected window address = message box address = menu address $96 = cursor y position within window $9b,$9c = selected gadget address = selected menu item address $9e = temporary $9f = cursor x position within window $a0-$a2 = RTC destroyed by interrupt $a3-$aa = temporary $b4,$b5 = pointer position x $b6 = pointer position y $bd = pointer configuration bits 2-3: acceleration bits 4-5: speed bit 6: mouse/joystick (1 = mouse) bit 7: port 1/port 2 (1 = port 2) $be = basic & desktop configuration bit 3: disable numeric keyboard bit 4: cursor blink bit 5: keyboard click bit 6: clock alarm enabled bit 7: clock displayed $c0 = used by kernel IRQ (tape motor flag) $c3,$c4 = temporary $c5 = used by kernel IRQ (last key pressed scancode) $c6 = number of characters in keyboard buffer (updated by kernel IRQ) $cb = key pressed scancode (used by kernel IRQ) $cc = used by kernel IRQ (cursor blink disabled) $cd = might be used by kernel IRQ (cursor blinking counter) $ce = might be used by kernel IRQ (character under cursor) $cf = might be used by kernel IRQ (cursor status) $d1,$d2 = might be used by kernel IRQ (current line address = $0400) $d3 = might be used by kernel IRQ (cursor column = 0) $f3 = might be used by kernel IRQ (cursor color ram address) $f5,$f6 = used by kernel IRQ (keyboard decoding table) $f7 = temporary $f8 = width / length of horizontal line $f9 = height / length of vertical line $fb,$fa = drawing position - column (destroyed by call #0e) $fc = drawing position - line (destroyed by call #0e) $fa,$fb = text address for text editing $fc = text length for text editing $fd = bit number in current drawing position $fe,$ff = address of current drawing position $0277-$0280 = keyboard buffer $0286 = might be used by kernel IRQ (current text color) $0287 = might be used by kernel IRQ (color under cursor) $0289 = keyboard buffer size (used by kernel IRQ) $028a = keyboard repeat flag (used by kernel IRQ) $028b = used by kernel IRQ (repeat speed counter) $028c = used by kernel IRQ (repeat delay counter) $028d = shift keys flag (updated by kernel IRQ) $028e = used by kernel IRQ (last shift keys) $0291 = used by kernel IRQ (enable C=+SHIFT combination) $0334-$0336 - indirect jump ($6C) used by $DE05 $0337 - JMP ($4C) $0338,$0339 - active window procedure $033a - JMP ($4C) $033b,$033c - vector used by other rom page $03c0 = next interrupt raster line $03c1 = pointer velocity $03c2 = pointer acceleration counter $03c3 = pointer acceleration $03c4 = pointer offset x for window move $03c5 = pointer offset y for window move $03c6 = pointer movement horizontal +left, -right $03c7 = pointer movement vertical +up, -down $03c8 = button pressed $03c9 = cursor area left edge $03ca,$03cb = cursor area right edge $03cc = cursor area top edge $03cd = cursor area bottom edge $03ce,$03cf = menu address $03d0 = disable screen buffer switching $03d1 = text cursor blinking delay counter $03d2 = text cursor blinking color number $03d3 = previous mouse value y $03d4 = previous mouse value x $03d5,$03d6 = temporary for mouse handler $c000,$c001 = selected window position $c002,$c003 = selected window size = string gadget position $c004 = selected window flags = string gadget attributes = msgbox buttons width $c005 = selected window title width = string gadget max. length $c006,$c007 = selected window gadgets = string gadget text address $c006 = msgbox flags $c008-$c00a = window drawing position (address and bit number) = saved drawing position $c00b = drag bar width $c00c-$c00e = temporary position for drawing window drag bar $c00f,$c010 = selected gadget position $c011,$c012 = selected gadget size = active and inactive menu item colors $c013 = selected gadget flags $c014,$c015 = next gadget $c016 = current position x MSB $c017 = pointer color 1 $c018 = pointer color 2 $c019 = foreground color $c01a = background/border color $c01b = port number and joystick/mouse selection $c01c = pointer velocity $c01d = pointer acceleration $c01e = border color in BASIC $c01f = BASIC flags bit 2: disable numberic keyboard bit 3: cursor blink bit 4: key repeat bit 5: keyboard click $c021,$c022 = free memory pointer for window backups $c023 = open windows count $c024-$c05f = open windows list $c060-$c134 = default menu data $c13f,$c140 = message box position $c14f,$c150 = message box size >8000 ; -- table of $de05 calls 01 - ($8100) ; -- fill x pages beginning from y page with value from $f7 02 - ($815d) ; -- set drawing position to x and y register 03 - ($8161) ; -- set drawing position (highest x bit in $fa) 04 - ($8199) ; -- horizontal line of length ($f8) 05 - ($81d8) ; -- vertical line of length ($f9) 06 - ($820b) ; -- rectangle of size x*y 07 - ($8233) ; -- foreground filled box of size x*y 08 - ($8237) ; -- background filled box of size x*y 09 - ($83a5) ; -- invert box of size x*y 0a - ($8408) ; -- text from address (x,y) with attributes from $f7 0b - ($8416) ; -- text from address ($a5) with attributes from $f7 0c - ($8520) ; -- move drawing position by x*y 0d - ($8563) ; -- draw rectangle with a shadow 0e - ($85bb) ; -- draw image 0f - ($85c6) ; -- draw image 10 - ($869c) ; -- grab image from screen 11 - ($8712) ; -- initizalize pointer 12 - ($87a1) ; -- disable pointer 13 - ($8bcd) ; -- drag window 14 - ($8e2e) ; -- switch output screen buffer 15 - ($8e42) ; -- switch visible screen buffer 16 - ($8d83) ; -- set default colors and preferences 17 - ($8d8e) ; -- update screen colors and preferences 18 - ($8d69) ; -- multiply bytes x*y 19 - ($8e74) ; -- draw single character (x) 1a - ($8e72) ; -- draw single character (x) 1b - ($8d97) ; -- refresh screen colors 1c - ($8f76) ; -- convert PETSCII to ASCII code 1d - ($8f93) ; -- select window 1e - ($8fde) ; -- draw window border 1f - ($90a4) ; -- set window drawing position address 20 - ($90b4) ; -- get window drawing position address 21 - ($90c7) ; -- draw window drag bar 22 - ($9117) ; -- select gadget 23 - ($914a) ; -- draw gadget 24 - ($91e6) ; -- set drawing position relative to gadget 25 - ($91f2) ; -- set drawing position relative to window 26 - ($920e) ; -- draw gadget text 27 - ($9235) ; -- draw image relative to window 28 - ($9265) ; -- save window snapshot 29 - ($92a5) ; -- restore window snapshot or redraw window 2a - ($92da) ; -- locate window on windows list 2b - ($92f8) ; -- insert window into list 2c - ($9316) ; -- remove window from list 2d - ($933b) ; -- move window to front of list 2e - ($9359) ; -- move window to back of list 2f - ($9384) ; -- clear window area 30 - ($9396) ; -- show window, address (x,y) 31 - ($93dc) ; -- get next window on list 32 - ($93f7) ; -- get previous window on list 33 - ($940d) ; -- handle button click 34 - ($947f) ; -- window hit test 35 - ($94b1) ; -- gadget hit test 36 - ($94d4) ; -- handle title bar clicked 37 - ($9767) ; -- handle gadget clicked 38 - ($97db) ; -- reverse gadget area 39 - ($97e1) ; -- reverse gadget area 3a - ($95ba) ; -- calculate string width 3b - ($97fe) ; -- update gadget in backup image 3c - ($ade8) ; -- handle menu clicked 3d - ($af9f) ; -- set menu item procedure 3e - ($98da) ; -- move window to front 3f - ($98e1) ; -- set window position 40 - ($9960) ; -- move window to back 41 - ($9981) ; -- close selected window 42 - ($9994) ; -- redraw all windows 43 - ($ac00) ; -- set menu address and draw menu 44 - ($92c3) ; -- redraw window 45 - ($99b7) ; -- draw zero-terminated texts list 46 - ($99d3) ; -- locate window on windows list 47 - ($9a01) ; -- initialize graphic mode and preferences 48 - ($9a13) ; -- switch to text mode 49 - ($b0d6) ; -- show small message box 4a - ($b0ec) ; -- show large message box 4b - ($b039) ; -- save screen area 4c - ($b068) ; -- restore screen area 4d - ($9248) ; -- draw gadget image 4e - ($b3c8) ; -- autodetect input device 4f - ($b026) ; -- display desktop version text 50 - ($b370) ; -- save set of zero-page registers in stack area 51 - ($b37f) ; -- restore zero-page registers and select top window 52 - ($b5ed) ; -- disable desktop, prepare for basic 53 - ($b4b9) ; -- load 54 - ($b56f) ; -- save 55 - ($9602) ; -- show text cursor at current position 56 - ($960e) ; -- hide text cursor 57 - ($b391) ; -- restore zero-page registers from stack area 58 - ($99f5) ; -- initialize graphic mode # call #01 - MEMORY FILL >8100 ; -- fill x pages beginning at page y with value from $f7 ] descr: ] Fill memory area ] input: ] y = first page ] x = number of pages ] $f7 = value ] uses: ] $c3,$c4 = fill address ,8100 a5 f7 LDA $f7 >8102 ; -- fill x pages beginning at page y with value of a ] descr: ] Fill memory area ] input: ] y = first page ] x = number of pages ] a = value ] uses: ] $c3,$c4 = fill address ,8102 84 c4 STY $c4 ,8104 a0 00 LDY #$00 ,8106 84 c3 STY $c3 ,8108 91 c3 STA ($c3),Y ,810a c8 INY ,810b d0 fb BNE $8108 ,810d e6 c4 INC $c4 ,810f ca DEX ,8110 d0 f6 BNE $8108 ,8112 60 RTS >8113 ; -- table of each 8-th line's offset :8113 00 00 01 40 02 80 03 c0 :811b 05 00 06 40 07 80 08 c0 :8123 0a 00 0b 40 0c 80 0d c0 :812b 0f 00 10 40 11 80 12 c0 :8133 14 00 15 40 16 80 17 c0 :813b 19 00 1a 40 1b 80 1c c0 :8143 1e 00 >8145 ; -- bit pattern for lines :8145 01 03 07 0f 1f 3f 7f ff :814d fe fc f8 f0 e0 c0 80 00 >8155 ; -- bit pattern for dots :8155 01 02 04 08 10 20 40 80 # call #02 - SET DRAWING POSITION >815d ; -- set drawing position to x and y register ] descr: ] Set current drawing position ] note: ] Column in range 0-255 ] input: ] $92 = address of active drawing screen ] x = column ] y = line ] output: ] $fa = highest bit of column (= 0) ] $fb = column ] $fc = line ] $fe,$ff = address of current drawing position ] $fd = bit number in current drawing position ,815d a9 00 LDA #$00 ,815f 85 fa STA $fa # call #03 - SET DRAWING POSITION >8161 ; -- set drawing position (highest x bit in $fa) ] descr: ] Set current drawing position ] input: ] $92 = address of active drawing screen ] $fa = highest bit of column ] x = column ] y = line ] output: ] $fb = column ] $fc = line ] $fe,$ff = address of current drawing position ] $fd = bit number in current drawing position ,8161 86 fb STX $fb ,8163 84 fc STY $fc >8165 ; -- set drawing position from ($fa,$fb,$fc) ] descr: ] Set current drawing position address ] input: ] $92 = address of active drawing screen ] $fa = highest bit of column ] $fb = column ] $fc = line ] output: ] $fe,$ff = address of current drawing position ] $fd = bit number in current drawing position ,8165 a5 fc LDA $fc ,8167 29 07 AND #$07 ,8169 85 fd STA $fd ; byte offset in char box ,816b a5 fc LDA $fc ,816d 29 f8 AND #$f8 ,816f 4a LSR ,8170 4a LSR ,8171 a8 TAY ,8172 be 13 81 LDX $8113,Y ; calculate address of beginning of char box line ,8175 b9 14 81 LDA $8114,Y ,8178 18 CLC ,8179 65 fb ADC $fb ; add char box number in line ,817b 29 f8 AND #$f8 ,817d 90 02 BCC $8181 ,817f e8 INX ,8180 18 CLC ,8181 65 fd ADC $fd ; add byte offset in line ,8183 85 fe STA $fe ,8185 a5 fa LDA $fa ,8187 f0 01 BEQ $818a ,8189 e8 INX ,818a 8a TXA ,818b 18 CLC ,818c 65 92 ADC $92 ; add screen address ,818e 85 ff STA $ff ,8190 a5 fb LDA $fb ; bit number ,8192 49 ff EOR #$ff ,8194 29 07 AND #$07 ,8196 85 fd STA $fd ,8198 60 RTS # call #04 - HORIZONTAL LINE >8199 ; -- draw a horizontal line of length ($f8) ] descr: ] Draw horizontal line ] input: ] $fd,$fe,$ff = current drawing position ] $f8 = length ] output: ] $fd,$fe,$ff = new drawing position ,8199 a6 fd LDX $fd ,819b bd 45 81 LDA $8145,X ; bit mask for left edge ,819e a0 00 LDY #$00 ,81a0 11 fe ORA ($fe),Y ,81a2 91 fe STA ($fe),Y ; draw left egde ,81a4 a5 f8 LDA $f8 ,81a6 18 CLC ,81a7 e5 fd SBC $fd ,81a9 48 PHA ; line lenght left ,81aa a0 08 LDY #$08 ,81ac 4a LSR ,81ad 4a LSR ,81ae 4a LSR ; byte-wide segments left ,81af f0 0d BEQ $81be ,81b1 aa TAX ,81b2 18 CLC ,81b3 a9 ff LDA #$ff ; draw byte segments ,81b5 91 fe STA ($fe),Y ,81b7 98 TYA ,81b8 69 08 ADC #$08 ; move rigth ,81ba a8 TAY ,81bb ca DEX ,81bc d0 f5 BNE $81b3 ,81be 68 PLA ,81bf 29 07 AND #$07 ,81c1 49 07 EOR #$07 ,81c3 85 fd STA $fd ; new bit number ,81c5 aa TAX ,81c6 bd 4c 81 LDA $814c,X ; bit mask for right edge ,81c9 11 fe ORA ($fe),Y ,81cb 91 fe STA ($fe),Y ,81cd 98 TYA ,81ce 18 CLC ,81cf 65 fe ADC $fe ; new drawing address ,81d1 85 fe STA $fe ,81d3 90 02 BCC $81d7 ,81d5 e6 ff INC $ff ,81d7 60 RTS # call #05 - VERTICAL LINE >81d8 ; -- draw a vertical line of length ($f9) ] descr: ] Draw vertical line ] input: ] $fd,$fe,$ff = current drawing position ] $f9 = length ] uses: ] $aa = bit pattern ] output: ] $fd,$fe,$ff = new drawing position ,81d8 a6 fd LDX $fd ,81da bd 55 81 LDA $8155,X ; line bit pattern ,81dd 85 aa STA $aa ,81df a5 fe LDA $fe ,81e1 29 07 AND #$07 ,81e3 a8 TAY ; offset in char box ,81e4 a5 fe LDA $fe ; beginning of char box ,81e6 29 f8 AND #$f8 ,81e8 85 fe STA $fe ,81ea a6 f9 LDX $f9 ,81ec a5 aa LDA $aa ; pixel loop ,81ee 11 fe ORA ($fe),Y ; draw single dot ,81f0 91 fe STA ($fe),Y ,81f2 c8 INY ,81f3 c0 08 CPY #$08 ,81f5 d0 0f BNE $8206 ,81f7 a0 00 LDY #$00 ; move to next char box ,81f9 18 CLC ,81fa a5 fe LDA $fe ,81fc 69 40 ADC #$40 ,81fe 85 fe STA $fe ,8200 a5 ff LDA $ff ,8202 69 01 ADC #$01 ,8204 85 ff STA $ff ,8206 ca DEX ,8207 d0 e3 BNE $81ec ,8209 f0 c2 BEQ $81cd ; new drawing address # call #06 - RECTANGLE >820b ; -- draw a rectangle of size x*y ] descr: ] Draw rectangle ] input: ] $fd,$fe,$ff = current drawing position ] x = width ] y = height ] uses: ] $f8 = width ] $f9 = height ] $c4,$f7,$c3 = copy of current drawing position ] $aa ] calls: ] $81d8 = vertical line ] $8199 = horizontal line ] output: ] $fd,$fe,$ff = new drawing position ,820b 86 f8 STX $f8 ; set width and height ,820d 84 f9 STY $f9 ,820f a5 fe LDA $fe ,8211 a6 ff LDX $ff ,8213 a4 fd LDY $fd ,8215 85 f7 STA $f7 ; save drawing position ,8217 86 c3 STX $c3 ,8219 84 c4 STY $c4 ,821b 20 d8 81 JSR $81d8 ; draw vertical line ,821e 20 99 81 JSR $8199 ; draw horizontal line ,8221 a5 f7 LDA $f7 ,8223 a6 c3 LDX $c3 ,8225 a4 c4 LDY $c4 ,8227 85 fe STA $fe ; restore drawing position ,8229 86 ff STX $ff ,822b 84 fd STY $fd ,822d 20 99 81 JSR $8199 ; draw horizontal line ,8230 4c d8 81 JMP $81d8 ; draw vertical line # call #07 - FOREGROUND FILLED BOX >8233 ; -- draw foreground filled box of size x*y ] descr: ] Draw box filled with foreground color ] input: ] $fd,$fe,$ff = current drawing position ] x = width ] y = height ] uses: ] $f8 = width ] $f9 = height ] $a5 ] $a6 = bytes to skip in top/bottom edge drawing routine ] $a7 = inner region width/height in char boxes ] $a8 = right edge bit number ] $a9 = inner region width ] $aa = fill pattern ] output: ] $fd,$fe,$ff = new drawing position ,8233 a9 ff LDA #$ff ,8235 d0 02 BNE $8239 # call #08 - BACKGROUND FILLED BOX >8237 ; -- draw background box of size x*y ] descr: ] Draw box filled with background color ] input: ] $fd,$fe,$ff = current drawing position ] x = width ] y = height ] uses: ] $f8 = width ] $f9 = height ] $a5 ] $a6 = bytes to skip in top/bottom edge drawing routine ] $a7 = inner region width/height in char boxes ] $a8 = right edge bit number ] $a9 = inner region width ] $aa = fill pattern ] output: ] $fd,$fe,$ff = new drawing position ,8237 a9 00 LDA #$00 ,8239 85 aa STA $aa ; fill bit pattern ,823b 86 f8 STX $f8 ; set width and height ,823d 84 f9 STY $f9 ,823f a9 00 LDA #$00 ,8241 85 a9 STA $a9 ,8243 a5 fd LDA $fd ,8245 49 07 EOR #$07 ; current bit number from left edge ,8247 18 CLC ,8248 65 f8 ADC $f8 ; add line width ,824a aa TAX ,824b 29 f8 AND #$f8 ,824d d0 03 BNE $8252 ,824f 4c 63 83 JMP $8363 ; entire box fits in char-wide column ,8252 38 SEC ,8253 e9 08 SBC #$08 ; box width excluding edges ,8255 85 a9 STA $a9 ,8257 8a TXA ,8258 49 07 EOR #$07 ,825a 29 07 AND #$07 ,825c 85 a8 STA $a8 ; bit number for right edge mask ,825e a5 fe LDA $fe ,8260 29 07 AND #$07 ,8262 a8 TAY ,8263 85 a6 STA $a6 ; char box byte offset ,8265 49 07 EOR #$07 ,8267 85 a5 STA $a5 ; bytes left in char box ,8269 a5 fe LDA $fe ,826b 29 f8 AND #$f8 ,826d 85 fe STA $fe ,826f 98 TYA ,8270 18 CLC ,8271 65 f9 ADC $f9 ; add height ,8273 c9 08 CMP #$08 ,8275 b0 1e BCS $8295 ,8277 38 SEC ; entire box fits in char-high line ,8278 a5 f9 LDA $f9 ,827a 49 07 EOR #$07 ,827c e5 a6 SBC $a6 ,827e 85 a5 STA $a5 ; distance between box bottom and end of char box ,8280 38 SEC ,8281 a5 fe LDA $fe ; adjust address for filling partial char box line ,8283 e5 a5 SBC $a5 ,8285 85 fe STA $fe ,8287 b0 02 BCS $828b ,8289 c6 ff DEC $ff ,828b a5 f9 LDA $f9 ,828d 49 07 EOR #$07 ,828f 85 a6 STA $a6 ; offset = 7 - height ,8291 a8 TAY ,8292 4c 13 83 JMP $8313 ; use top/bottom edge drawing routine ,8295 20 13 83 JSR $8313 ; draw top edge ,8298 18 CLC ; move to next char-box line ,8299 a5 fe LDA $fe ,829b 69 40 ADC #$40 ,829d 85 fe STA $fe ,829f a5 ff LDA $ff ,82a1 69 01 ADC #$01 ,82a3 85 ff STA $ff ,82a5 a5 f9 LDA $f9 ,82a7 18 CLC ,82a8 e5 a5 SBC $a5 ; height excluding top edge ,82aa aa TAX ,82ab 49 ff EOR #$ff ,82ad 29 07 AND #$07 ,82af 85 a6 STA $a6 ; bytes to skip for bottom edge ,82b1 8a TXA ,82b2 4a LSR ,82b3 4a LSR ,82b4 4a LSR ,82b5 85 a7 STA $a7 ; inner region height in char boxes ,82b7 f0 4d BEQ $8306 ; -- char-box line loop ; -- left edge ,82b9 a0 07 LDY #$07 ,82bb a6 fd LDX $fd ,82bd b1 fe LDA ($fe),Y ; get screen byte ,82bf 3d 4d 81 AND $814d,X ; mask ,82c2 24 aa BIT $aa ,82c4 10 03 BPL $82c9 ,82c6 1d 45 81 ORA $8145,X ; fill right side ,82c9 91 fe STA ($fe),Y ; update screen byte ,82cb 88 DEY ,82cc 10 ef BPL $82bd ; close byte loop ,82ce a0 08 LDY #$08 ,82d0 84 a5 STY $a5 ; -- inner region ,82d2 a6 a9 LDX $a9 ; inner region width ,82d4 f0 0a BEQ $82e0 ,82d6 a9 00 LDA #$00 ,82d8 05 aa ORA $aa ,82da 91 fe STA ($fe),Y ; put screen byte ,82dc c8 INY ,82dd ca DEX ,82de d0 fa BNE $82da ; close byte loop ; -- right edge ,82e0 a6 a8 LDX $a8 ,82e2 b1 fe LDA ($fe),Y ; get screen byte ,82e4 3d 44 81 AND $8144,X ; mask ,82e7 24 aa BIT $aa ,82e9 10 03 BPL $82ee ,82eb 1d 4c 81 ORA $814c,X ; fill left side ,82ee 91 fe STA ($fe),Y ; update screen byte ,82f0 c8 INY ,82f1 c6 a5 DEC $a5 ,82f3 d0 ed BNE $82e2 ; close byte loop ,82f5 18 CLC ; next char-box line ,82f6 a5 fe LDA $fe ,82f8 69 40 ADC #$40 ,82fa 85 fe STA $fe ,82fc a5 ff LDA $ff ,82fe 69 01 ADC #$01 ,8300 85 ff STA $ff ,8302 c6 a7 DEC $a7 ,8304 d0 b3 BNE $82b9 ; close char box line loop ,8306 38 SEC ; adjust address for filling bottom edge ,8307 a5 fe LDA $fe ,8309 e5 a6 SBC $a6 ,830b 85 fe STA $fe ,830d b0 02 BCS $8311 ,830f c6 ff DEC $ff ,8311 a4 a6 LDY $a6 ; -- top/bottom edge ; -- left top/bottom corner ,8313 a6 fd LDX $fd ; bit number ,8315 b1 fe LDA ($fe),Y ; get screen byte ,8317 3d 4d 81 AND $814d,X ; mask ,831a 24 aa BIT $aa ,831c 10 03 BPL $8321 ,831e 1d 45 81 ORA $8145,X ; fill right side ,8321 91 fe STA ($fe),Y ; update screen byte ,8323 c8 INY ,8324 98 TYA ,8325 29 07 AND #$07 ,8327 d0 ec BNE $8315 ; byte loop ,8329 98 TYA ,832a 18 CLC ,832b 65 a6 ADC $a6 ; skip lines outside box ,832d a8 TAY ; -- top/bottom edge inner region ,832e a5 a9 LDA $a9 ; width excluding corners ,8330 4a LSR ,8331 4a LSR ,8332 4a LSR ,8333 f0 17 BEQ $834c ,8335 85 a7 STA $a7 ; inner region width in char boxes ,8337 a9 00 LDA #$00 ,8339 05 aa ORA $aa ,833b 91 fe STA ($fe),Y ; put screen byte ,833d c8 INY ,833e 98 TYA ,833f 29 07 AND #$07 ,8341 d0 f4 BNE $8337 ; byte loop ,8343 98 TYA ,8344 18 CLC ,8345 65 a6 ADC $a6 ; skip lines outside box ,8347 a8 TAY ,8348 c6 a7 DEC $a7 ,834a d0 eb BNE $8337 ; char box loop ; -- right top/bottom corner ,834c a6 a8 LDX $a8 ; bit number ,834e b1 fe LDA ($fe),Y ; get screen byte ,8350 3d 44 81 AND $8144,X ; mask ,8353 24 aa BIT $aa ,8355 10 03 BPL $835a ,8357 1d 4c 81 ORA $814c,X ; fill left side ,835a 91 fe STA ($fe),Y ; update screen byte ,835c c8 INY ,835d 98 TYA ,835e 29 07 AND #$07 ,8360 d0 ec BNE $834e ; byte loop ,8362 60 RTS ; -- narrow box ,8363 8a TXA ; narrow box ,8364 49 07 EOR #$07 ,8366 aa TAX ,8367 bd 44 81 LDA $8144,X ; right side mask ,836a a6 fd LDX $fd ,836c 1d 4d 81 ORA $814d,X ; left side mask ,836f 85 a5 STA $a5 ; combined mask ,8371 49 ff EOR #$ff ,8373 25 aa AND $aa ,8375 85 a6 STA $a6 ; masked fill pattern ,8377 a5 fe LDA $fe ; move char box offset to y ,8379 29 07 AND #$07 ,837b a8 TAY ,837c a5 fe LDA $fe ,837e 29 f8 AND #$f8 ,8380 85 fe STA $fe ,8382 a6 f9 LDX $f9 ; height ,8384 e8 INX ,8385 b1 fe LDA ($fe),Y ; get screen byte ,8387 25 a5 AND $a5 ; mask ,8389 05 a6 ORA $a6 ,838b 91 fe STA ($fe),Y ; update screen byte ,838d c8 INY ,838e c0 08 CPY #$08 ,8390 d0 0f BNE $83a1 ,8392 a0 00 LDY #$00 ; char box bottom edge ,8394 18 CLC ,8395 a5 fe LDA $fe ,8397 69 40 ADC #$40 ,8399 85 fe STA $fe ,839b a5 ff LDA $ff ,839d 69 01 ADC #$01 ,839f 85 ff STA $ff ,83a1 ca DEX ,83a2 d0 e1 BNE $8385 ; close line loop ,83a4 60 RTS # call #09 - INVERT BOX >83a5 ; -- draw a xor'ed box of size x*y ] descr: ] Draw inverted box ] input: ] $fd,$fe,$ff = current drawing position ] x = width ] y = height ] uses: ] $f8 = width ] $f9 = height ] $a7 ] $a8 = inner region width in char-boxes ] $a9 = left edge mask ] $aa = right edge mask ] output: ] $fd,$fe,$ff = new drawing position ,83a5 86 f8 STX $f8 ; set width and height ,83a7 84 f9 STY $f9 ,83a9 a6 fd LDX $fd ,83ab bd 45 81 LDA $8145,X ; left edge mask ,83ae 85 aa STA $aa ,83b0 a5 f8 LDA $f8 ,83b2 18 CLC ,83b3 e5 fd SBC $fd ,83b5 a8 TAY ,83b6 49 ff EOR #$ff ,83b8 29 07 AND #$07 ,83ba aa TAX ,83bb bd 4c 81 LDA $814c,X ; right edge mask ,83be 85 a9 STA $a9 ,83c0 98 TYA ,83c1 4a LSR ,83c2 4a LSR ,83c3 4a LSR ,83c4 85 a8 STA $a8 ; inner region width in char-boxes ,83c6 a5 f9 LDA $f9 ,83c8 85 a7 STA $a7 ; setup line counter ,83ca a0 00 LDY #$00 ,83cc b1 fe LDA ($fe),Y ; xor left edge ,83ce 45 aa EOR $aa ,83d0 91 fe STA ($fe),Y ,83d2 a6 a8 LDX $a8 ; byte counter ,83d4 10 06 BPL $83dc ,83d6 b1 fe LDA ($fe),Y ; xor byte ,83d8 49 ff EOR #$ff ,83da 91 fe STA ($fe),Y ,83dc 98 TYA ; move right ,83dd 18 CLC ,83de 69 08 ADC #$08 ,83e0 a8 TAY ,83e1 ca DEX ; decrement counter ,83e2 10 f2 BPL $83d6 ; close byte loop ,83e4 b1 fe LDA ($fe),Y ; xor right edge ,83e6 45 a9 EOR $a9 ,83e8 91 fe STA ($fe),Y ,83ea e6 fe INC $fe ; move pointer down ,83ec d0 02 BNE $83f0 ,83ee e6 ff INC $ff ,83f0 a5 fe LDA $fe ,83f2 29 07 AND #$07 ,83f4 d0 0d BNE $8403 ,83f6 18 CLC ; char-box line crossing ,83f7 a5 fe LDA $fe ,83f9 69 38 ADC #$38 ,83fb 85 fe STA $fe ,83fd a5 ff LDA $ff ,83ff 69 01 ADC #$01 ,8401 85 ff STA $ff ,8403 c6 a7 DEC $a7 ,8405 10 c3 BPL $83ca ; close line loop ,8407 60 RTS # call #0a - PUT TEXT >8408 ; -- put text from address (x,y) with attributes from $f7 ] descr: ] Draw text ] input: ] $fd,$fe,$ff = current drawing position ] $f7 = text attributes ] bits 0-2: spacing ] bit 5: double height ] bit 6: double width ( characters must be repeated ) ] bit 7: bold ] x,y = text address ] uses: ] $a5,$a6 = text address ] $a3,$a4 = address of line in character definition ] $a7 = line count ] $f8 = copy of $fd ] $a8 = character index ] $a9 = character width ] $c3,$c4 = spacing ] $aa = bit pattern ] $f9 = screen address offset ] $fd,$fe,$ff = current drawing position ] output: ] y = string length ,8408 a5 f7 LDA $f7 >840a ; -- put text from address (x,y) with attributes from A ] descr: ] Draws text ] input: ] $fd,$fe,$ff = current drawing position ] a = text attributes ] bits 0-2: spacing ] bit 5: double height ] bit 6: double width ( characters must be repeated ) ] bit 7: bold ] x,y = text address ] uses: ] $a5,$a6 = text address ] $a3,$a4 = address of line in character definition ] $a7 = line count ] $f8 = copy of $fd ] $a8 = character index ] $a9 = character width ] $c3,$c4 = spacing ] $aa = bit pattern ] $f9 = screen address offset ] $fd,$fe,$ff = current drawing position ] output: ] y = string length ,840a 85 f7 STA $f7 ,840c 29 07 AND #$07 ,840e 85 c3 STA $c3 ; character spacing ,8410 85 c4 STA $c4 ,8412 86 a5 STX $a5 ; set text address ,8414 84 a6 STY $a6 # call #0b - PUT TEXT >8416 ; -- put text from address ($a5) with attributes from $f7 ] descr: ] Draw text ] input: ] $fd,$fe,$ff = current drawing position ] $f7 = text attributes ] bit 5: double height ] bit 6: double width ( characters must be repeated ) ] bit 7: bold ] $c3,$c4 = spacing ] x,y = text address ] uses: ] $a5,$a6 = text address ] $a3,$a4 = address of line in character definition ] $a7 = line count ] $f8 = copy of $fd ] $a8 = character index ] $a9 = character width ] $aa = bit pattern ] $f9 = screen address offset ] $fd,$fe,$ff = current drawing position ] output: ] y = string length ,8416 a2 92 LDX #$92 ,8418 a0 a1 LDY #$a1 ,841a 86 a3 STX $a3 ; setup character matrix address ($a1a2 - $10) ,841c 84 a4 STY $a4 ,841e a2 09 LDX #$09 ; height 9px ,8420 a5 f7 LDA $f7 ; attributes ,8422 29 20 AND #$20 ; double height ,8424 f0 02 BEQ $8428 ,8426 a2 12 LDX #$12 ; height 18px ,8428 86 a7 STX $a7 ; setup line counter ,842a a5 fd LDA $fd ,842c 85 f8 STA $f8 ; save bit number ; -- line loop ,842e a9 00 LDA #$00 ,8430 85 f9 STA $f9 ; reset screen address offset ,8432 85 a8 STA $a8 ; reset character index ,8434 a5 f8 LDA $f8 ,8436 85 fd STA $fd ; reset x position ; -- character loop ,8438 a4 a8 LDY $a8 ; character index ,843a b1 a5 LDA ($a5),Y ; get next text character ,843c 10 08 BPL $8446 ,843e c9 a0 CMP #$a0 ; adjust character code ,8440 d0 02 BNE $8444 ,8442 a9 80 LDA #$80 ,8444 49 a0 EOR #$a0 ,8446 d0 36 BNE $847e ; put character scanline on screen ,8448 c6 a7 DEC $a7 ; next line ,844a d0 01 BNE $844d ,844c 60 RTS ; -- next line ,844d a5 f7 LDA $f7 ; text attributes ,844f 29 20 AND #$20 ,8451 f0 05 BEQ $8458 ,8453 a5 a7 LDA $a7 ; double height ,8455 4a LSR ,8456 b0 0b BCS $8463 ; odd line number ,8458 18 CLC ; move character definiton address to next line ,8459 a5 a3 LDA $a3 ,845b 69 6f ADC #$6f ,845d 85 a3 STA $a3 ,845f 90 02 BCC $8463 ,8461 e6 a4 INC $a4 ,8463 e6 fe INC $fe ; move screen address to next line ,8465 d0 02 BNE $8469 ,8467 e6 ff INC $ff ,8469 a5 fe LDA $fe ,846b 29 07 AND #$07 ,846d d0 bf BNE $842e ,846f 18 CLC ; char-box line crossong ,8470 a5 fe LDA $fe ,8472 69 38 ADC #$38 ,8474 85 fe STA $fe ,8476 a5 ff LDA $ff ,8478 69 01 ADC #$01 ,847a 85 ff STA $ff ,847c d0 b0 BNE $842e ; always jumps ,847e a8 TAY ; character code ,847f b9 79 a5 LDA $a579,Y ; character width ,8482 85 a9 STA $a9 ,8484 b1 a3 LDA ($a3),Y ; scanline bit pattern ,8486 24 f7 BIT $f7 ; text attributes ,8488 10 07 BPL $8491 ,848a e6 a9 INC $a9 ; bold text ,848c 85 aa STA $aa ,848e 4a LSR ,848f 05 aa ORA $aa ; make bold ,8491 24 f7 BIT $f7 ,8493 50 3f BVC $84d4 ,8495 85 aa STA $aa ; double width ,8497 a2 04 LDX #$04 ,8499 a5 a8 LDA $a8 ; character index ,849b 29 01 AND #$01 ,849d d0 1a BNE $84b9 ; -- double width - even character ,849f a5 a9 LDA $a9 ; character width ,84a1 0a ASL ; *2 ,84a2 c9 07 CMP #$07 ,84a4 90 02 BCC $84a8 ,84a6 a9 07 LDA #$07 ; limit to 7 ,84a8 85 a9 STA $a9 ,84aa a9 00 LDA #$00 ; set character spacing to 0 ,84ac 85 c3 STA $c3 ,84ae 06 aa ASL $aa ; widen bit pattern ,84b0 08 PHP ,84b1 2a ROL ,84b2 28 PLP ,84b3 2a ROL ,84b4 ca DEX ,84b5 d0 f7 BNE $84ae ,84b7 f0 1b BEQ $84d4 ; -- double width - odd character ,84b9 a5 c4 LDA $c4 ,84bb 85 c3 STA $c3 ; restore spacing ,84bd a5 a9 LDA $a9 ; character width ,84bf 0a ASL ; *2 ,84c0 38 SEC ,84c1 e9 07 SBC #$07 ; -7 ,84c3 b0 02 BCS $84c7 ,84c5 a9 00 LDA #$00 ; if width was < 7, set to 0 ,84c7 85 a9 STA $a9 ,84c9 a9 00 LDA #$00 ,84cb 46 aa LSR $aa ; widen bit pattern ,84cd 08 PHP ,84ce 6a ROR ,84cf 28 PLP ,84d0 6a ROR ,84d1 ca DEX ,84d2 d0 f7 BNE $84cb ,84d4 85 aa STA $aa ; save bit pattern ,84d6 c9 00 CMP #$00 ,84d8 f0 15 BEQ $84ef ,84da a5 fd LDA $fd ; get bit number ,84dc 49 07 EOR #$07 ,84de aa TAX ,84df a5 aa LDA $aa ; shift bit pattern right ,84e1 a0 00 LDY #$00 ,84e3 84 aa STY $aa ,84e5 e0 00 CPX #$00 ; number of shifts ,84e7 f0 06 BEQ $84ef ,84e9 4a LSR ,84ea 66 aa ROR $aa ,84ec ca DEX ,84ed d0 fa BNE $84e9 ,84ef a4 f9 LDY $f9 ; screen offset ,84f1 51 fe EOR ($fe),Y ,84f3 91 fe STA ($fe),Y ; put character to screen ,84f5 a5 fd LDA $fd ,84f7 18 CLC ,84f8 e5 a9 SBC $a9 ,84fa 29 07 AND #$07 ,84fc b0 0f BCS $850d ; character fits in single byte ,84fe aa TAX ; new bit number ,84ff 98 TYA ; move screen pointer one char right ,8500 69 08 ADC #$08 ,8502 a8 TAY ,8503 a5 aa LDA $aa ; get second byte of shifted bit pattern ,8505 f0 04 BEQ $850b ,8507 51 fe EOR ($fe),Y ,8509 91 fe STA ($fe),Y ,850b 8a TXA ,850c 38 SEC ,850d e5 c3 SBC $c3 ; add spacing ,850f 29 07 AND #$07 ,8511 85 fd STA $fd ; save new bit number ,8513 b0 04 BCS $8519 ,8515 98 TYA ; move pointer one char right ,8516 69 08 ADC #$08 ,8518 a8 TAY ,8519 84 f9 STY $f9 ,851b e6 a8 INC $a8 ; next character ,851d 4c 38 84 JMP $8438 # call #0c - MOVE DRAWING POSITION >8520 ; -- move drawing position by x*y ] descr: ] Move current drawing position ] input: ] $fd,$fe,$ff = current drawing position ] x = columns ] y = lines ] uses: ] $aa ] output: ] $fd,$fe,$ff = new drawing position ,8520 84 aa STY $aa ,8522 8a TXA ,8523 18 CLC ,8524 69 08 ADC #$08 ,8526 e5 fd SBC $fd ,8528 a8 TAY ,8529 49 ff EOR #$ff ,852b 29 07 AND #$07 ,852d 85 fd STA $fd ,852f 98 TYA ,8530 29 f8 AND #$f8 ,8532 18 CLC ,8533 65 fe ADC $fe ,8535 85 fe STA $fe ,8537 90 02 BCC $853b ,8539 e6 ff INC $ff ,853b 29 07 AND #$07 ,853d 18 CLC ,853e 65 aa ADC $aa ,8540 a8 TAY ,8541 29 07 AND #$07 ,8543 85 aa STA $aa ,8545 a5 fe LDA $fe ,8547 29 f8 AND #$f8 ,8549 85 fe STA $fe ,854b 98 TYA ,854c 29 f8 AND #$f8 ,854e 4a LSR ,854f 4a LSR ,8550 aa TAX ,8551 a5 fe LDA $fe ,8553 18 CLC ,8554 65 aa ADC $aa ,8556 7d 14 81 ADC $8114,X ,8559 85 fe STA $fe ,855b a5 ff LDA $ff ,855d 7d 13 81 ADC $8113,X ,8560 85 ff STA $ff ,8562 60 RTS # call #0d - DRAW RECTANGLE WITH SHADOW >8563 ; -- draw rectangle with a shadow ] descr: ] Draw rectangle with shadow on right and bottom edges ] input: ] $fd,$fe,$ff = current drawing position ] x = width ] y = height ] uses: ] $f8 = width ] $f9 = height ] $c4,$f7,$c3 = copy of current drawing position ] $aa ] calls: ] $81d8 = vertical line ] $8199 = horizontal line ] $8520 = move drawing position ] output: ] $fd,$fe,$ff = new drawing position ,8563 86 f8 STX $f8 ,8565 84 f9 STY $f9 ,8567 a5 fe LDA $fe ; save cursor position ,8569 a6 ff LDX $ff ,856b a4 fd LDY $fd ,856d 85 f7 STA $f7 ,856f 86 c3 STX $c3 ,8571 84 c4 STY $c4 ,8573 20 d8 81 JSR $81d8 ; vertical line ,8576 20 99 81 JSR $8199 ; horizonal line ,8579 a5 f7 LDA $f7 ; restore cursor position ,857b a6 c3 LDX $c3 ,857d a4 c4 LDY $c4 ,857f 85 fe STA $fe ,8581 86 ff STX $ff ,8583 84 fd STY $fd ,8585 20 99 81 JSR $8199 ; horizontal line ,8588 20 d8 81 JSR $81d8 ; vertical line ,858b a5 f7 LDA $f7 ; shadow at bottom side ,858d a6 c3 LDX $c3 ,858f a4 c4 LDY $c4 ,8591 85 fe STA $fe ,8593 86 ff STX $ff ,8595 84 fd STY $fd ,8597 a6 f8 LDX $f8 ,8599 a0 02 LDY #$02 ,859b e8 INX ,859c 20 20 85 JSR $8520 ; move drawing position ,859f 20 d8 81 JSR $81d8 ; vertical line ,85a2 a5 f7 LDA $f7 ; shadow at right side ,85a4 a6 c3 LDX $c3 ,85a6 a4 c4 LDY $c4 ,85a8 85 fe STA $fe ,85aa 86 ff STX $ff ,85ac 84 fd STY $fd ,85ae a2 02 LDX #$02 ,85b0 a4 f9 LDY $f9 ,85b2 c8 INY ,85b3 20 20 85 JSR $8520 ; move drawing position ,85b6 c6 f8 DEC $f8 ,85b8 4c 99 81 JMP $8199 ; horizontal line # call #0e - DRAW IMAGE FROM ADDRESS (x,y) >85bb ; -- draw image from address (x,y) ] descr: ] Draw image in FCIII image format on screen ] note: ] Image format: w-1, h-1, shift count (normally=7), scanline width, pixels ] input: ] $fd,$fe,$ff = current drawing position ] x,y = image address ] uses: ] $fa,fb = address ] $f8 = width ] $f9 = height ] $9e,$a3-$aa,$c3,$c4,$f7,$fc ] output: ] $fd,$fe,$ff = new drawing position ,85bb 86 fa STX $fa ; save address ,85bd 84 fb STY $fb ,85bf a0 00 LDY #$00 ,85c1 b1 fa LDA ($fa),Y ; save width ,85c3 85 f8 STA $f8 ,85c5 c8 INY # call #0f - DRAW IMAGE FROM ADDRESS ($fa) >85c6 ; -- draw image from address ($fa); y should be 1 and $f8 should contain image width ] descr: ] Draw image in FCIII image format on screen ] input: ] $fd,$fe,$ff = current drawing position ] $fa,$fb = image address ] $f8 = width (may be less than actual image width) ] y = 1 (offset from image address, width byte skipped) ] uses: ] $f9 = height ] $9e,$a3-$aa,$c3,$c4,$f7,$fc ] output: ] $fd,$fe,$ff = new drawing position ,85c6 b1 fa LDA ($fa),Y ; save height ,85c8 85 f9 STA $f9 ,85ca c8 INY ,85cb b1 fa LDA ($fa),Y ; save bit number (image shift count) ,85cd 85 9e STA $9e ,85cf c8 INY ,85d0 b1 fa LDA ($fa),Y ; save scanline width in bytes ,85d2 85 fc STA $fc ,85d4 c8 INY ,85d5 98 TYA ; skip header data ,85d6 18 CLC ,85d7 65 fa ADC $fa ,85d9 85 fa STA $fa ,85db 90 02 BCC $85df ,85dd e6 fb INC $fb ,85df a6 fd LDX $fd ,85e1 bd 4d 81 LDA $814d,X ; get left-edge mask ,85e4 85 c4 STA $c4 ,85e6 8a TXA ,85e7 49 07 EOR #$07 ,85e9 18 CLC ,85ea 65 f8 ADC $f8 ,85ec a8 TAY ,85ed 49 07 EOR #$07 ,85ef 29 07 AND #$07 ,85f1 aa TAX ,85f2 bd 44 81 LDA $8144,X ; get right-edge mask ,85f5 85 c3 STA $c3 ,85f7 98 TYA ,85f8 29 f8 AND #$f8 ,85fa 85 aa STA $aa ; screen line offset ,85fc 4a LSR ,85fd 4a LSR ,85fe 4a LSR ,85ff 85 f7 STA $f7 ; byte count ,8601 a2 00 LDX #$00 ,8603 38 SEC ,8604 a5 9e LDA $9e ; calculate shift count ,8606 e5 fd SBC $fd ,8608 b0 03 BCS $860d ,860a e8 INX ,860b 29 07 AND #$07 ,860d 85 fd STA $fd ,860f 86 f8 STX $f8 ,8611 e6 f9 INC $f9 ,8613 a5 f7 LDA $f7 ; scanline loop ,8615 85 a9 STA $a9 ,8617 a4 aa LDY $aa ; get rightmost screen byte ,8619 b1 fe LDA ($fe),Y ,861b 25 c3 AND $c3 ; keep extern pixels ,861d 85 a3 STA $a3 ,861f a0 00 LDY #$00 ,8621 84 a7 STY $a7 ,8623 b1 fe LDA ($fe),Y ; get leftmost screen byte ,8625 25 c4 AND $c4 ; keep extern pixels ,8627 85 a8 STA $a8 ,8629 a5 f8 LDA $f8 ,862b f0 03 BEQ $8630 ; get leftmost image byte ,862d b1 fa LDA ($fa),Y ,862f c8 INY ,8630 85 a6 STA $a6 ,8632 84 a5 STY $a5 ,8634 a4 a5 LDY $a5 ; byte loop ,8636 b1 fa LDA ($fa),Y ; get next image byte ,8638 85 a4 STA $a4 ,863a a6 fd LDX $fd ,863c f0 06 BEQ $8644 ,863e 46 a6 LSR $a6 ; rotate right with neighbour byte ,8640 6a ROR ,8641 ca DEX ,8642 d0 fa BNE $863e ,8644 a4 a7 LDY $a7 ,8646 91 fe STA ($fe),Y ; put to screen memory ,8648 98 TYA ,8649 18 CLC ,864a 69 08 ADC #$08 ; move screen ptr right ,864c 85 a7 STA $a7 ,864e a5 a4 LDA $a4 ,8650 85 a6 STA $a6 ,8652 e6 a5 INC $a5 ,8654 c6 a9 DEC $a9 ,8656 10 dc BPL $8634 ; close byte loop ,8658 a4 aa LDY $aa ; update rightmost byte ,865a a5 c3 LDA $c3 ,865c 49 ff EOR #$ff ,865e 31 fe AND ($fe),Y ,8660 05 a3 ORA $a3 ,8662 91 fe STA ($fe),Y ,8664 a0 00 LDY #$00 ; update leftmost byte ,8666 a5 c4 LDA $c4 ,8668 49 ff EOR #$ff ,866a 31 fe AND ($fe),Y ,866c 05 a8 ORA $a8 ,866e 91 fe STA ($fe),Y ,8670 18 CLC ; move image pointer to next line ,8671 a5 fa LDA $fa ,8673 65 fc ADC $fc ,8675 85 fa STA $fa ,8677 90 02 BCC $867b ,8679 e6 fb INC $fb ,867b e6 fe INC $fe ; move screen pointer to next line ,867d d0 02 BNE $8681 ,867f e6 ff INC $ff ,8681 a5 fe LDA $fe ,8683 29 07 AND #$07 ,8685 d0 0d BNE $8694 ,8687 18 CLC ,8688 a5 fe LDA $fe ,868a 69 38 ADC #$38 ,868c 85 fe STA $fe ,868e a5 ff LDA $ff ,8690 69 01 ADC #$01 ,8692 85 ff STA $ff ,8694 c6 f9 DEC $f9 ,8696 f0 03 BEQ $869b ,8698 4c 13 86 JMP $8613 ; close scanline loop ,869b 60 RTS # call #10 - GRAB IMAGE TO ADDRESS (x,y) >869c ; -- grab an image to address (x,y) of width ($f8) and height ($f9) ] descr: ] Create image in FCIII format from screen ] input: ] $fd,$fe,$ff = current drawing position ] x,y = image buffer address ] $f8 = width ] $f9 = height ] uses: ] $c3,$c4 = address ] $9e,$aa,$f7 ] output: ] x,y = pointer to end of data ,869c 86 c3 STX $c3 ; save buffer address ,869e 84 c4 STY $c4 ,86a0 a5 fd LDA $fd ,86a2 49 07 EOR #$07 ,86a4 18 CLC ,86a5 65 f8 ADC $f8 ,86a7 4a LSR ,86a8 4a LSR ,86a9 4a LSR ,86aa 85 9e STA $9e ,86ac a0 00 LDY #$00 ; put width and height into header ,86ae a5 f8 LDA $f8 ,86b0 91 c3 STA ($c3),Y ,86b2 c8 INY ,86b3 a5 f9 LDA $f9 ,86b5 91 c3 STA ($c3),Y ,86b7 c8 INY ,86b8 a5 fd LDA $fd ; put shift count into header ,86ba 91 c3 STA ($c3),Y ,86bc c8 INY ,86bd a5 9e LDA $9e ; put scanline width in bytes into header ,86bf aa TAX ,86c0 18 CLC ,86c1 69 01 ADC #$01 ,86c3 91 c3 STA ($c3),Y ,86c5 c8 INY ,86c6 84 aa STY $aa ,86c8 e6 f9 INC $f9 ,86ca a9 00 LDA #$00 ; reset screen offset ,86cc f0 05 BEQ $86d3 ,86ce a5 f7 LDA $f7 ; byte loop ,86d0 18 CLC ,86d1 69 08 ADC #$08 ; move screen pointer right ,86d3 85 f7 STA $f7 ; scanline loop ,86d5 a8 TAY ,86d6 b1 fe LDA ($fe),Y ; get screen byte ,86d8 a4 aa LDY $aa ,86da 91 c3 STA ($c3),Y ; put into image ,86dc e6 aa INC $aa ; move image pointer to next byte ,86de d0 02 BNE $86e2 ,86e0 e6 c4 INC $c4 ,86e2 ca DEX ,86e3 10 e9 BPL $86ce ; close byte loop ,86e5 e6 fe INC $fe ; move screen pointer to next scanline ,86e7 d0 02 BNE $86eb ,86e9 e6 ff INC $ff ,86eb a5 fe LDA $fe ,86ed 29 07 AND #$07 ,86ef d0 0d BNE $86fe ,86f1 18 CLC ,86f2 a5 fe LDA $fe ,86f4 69 38 ADC #$38 ,86f6 85 fe STA $fe ,86f8 a5 ff LDA $ff ,86fa 69 01 ADC #$01 ,86fc 85 ff STA $ff ,86fe a9 00 LDA #$00 ,8700 a6 9e LDX $9e ,8702 c6 f9 DEC $f9 ,8704 d0 cd BNE $86d3 ; close scanline loop ,8706 a4 c4 LDY $c4 ; return pointer to buffer end ,8708 18 CLC ,8709 a5 c3 LDA $c3 ,870b 65 aa ADC $aa ,870d 90 01 BCC $8710 ,870f c8 INY ,8710 aa TAX ,8711 60 RTS # call #11 - INITIALIZE POINTER >8712 ; -- initialize pointer ] descr: ] Copy cursor sprites image ] Initialize and enable cursor sprites ] Install interrupt vector for cursor ] Enable raster interrupt ] input: ] $bd = pointer configuration ] bits 4-5: cursor speed ] output: ] $0314,$0315 = interrupt vector ] $03c0 = interrupt raster line ] $03c1 = cursor speed ] $03c8 = button pressed flag ] $03c9-$03cc = cursor movement area ,8712 a0 20 LDY #$20 ; setup sprites for page 1 @ $0800 ,8714 a2 07 LDX #$07 ,8716 98 TYA ,8717 99 d8 07 STA $07d8,Y ,871a c8 INY ,871b ca DEX ,871c d0 f8 BNE $8716 ,871e a0 90 LDY #$90 ; setup sprites for page 2 @ $6400 ,8720 a2 07 LDX #$07 ,8722 98 TYA ,8723 99 68 63 STA $6368,Y ,8726 c8 INY ,8727 ca DEX ,8728 d0 f8 BNE $8722 ,872a a0 00 LDY #$00 ; copy sprites ,872c b9 f8 a5 LDA $a5f8,Y ,872f 99 00 08 STA $0800,Y ,8732 99 00 64 STA $6400,Y ,8735 b9 b8 a6 LDA $a6b8,Y ,8738 99 c0 08 STA $08c0,Y ,873b 99 c0 64 STA $64c0,Y ,873e c8 INY ,873f d0 eb BNE $872c >8741 ; -- reenable pointer ] descr: ] Enable cursor sprites ] Install interrupt vector for cursor ] Enable raster interrupt ] input: ] $bd = pointer configuration ] bits 4-5: cursor speed ] output: ] $0314,$0315 = interrupt vector ] $03c0 = interrupt raster line ] $03c1 = cursor speed ] $03c8 = button pressed flag ] $03c9-$03cc = cursor movement area ,8741 a5 bd LDA $bd ,8743 4a LSR ,8744 4a LSR ,8745 4a LSR ,8746 4a LSR ,8747 29 03 AND #$03 ,8749 8d c1 03 STA $03c1 ; cursor speed ,874c a9 00 LDA #$00 ; setup sprites ,874e 8d 17 d0 STA $d017 ; expand vertical = 0 ,8751 8d 1d d0 STA $d01d ; expand horizontal = 0 ,8754 8d 1c d0 STA $d01c ; multicolor = 0 ,8757 8d 1b d0 STA $d01b ; background priority = 0 ,875a 8d 10 d0 STA $d010 ; x position MSB = 0 ,875d a9 03 LDA #$03 ,875f 8d 15 d0 STA $d015 ; enable sprites 0 and 1 (cursor) ,8762 a9 00 LDA #$00 ,8764 8d c8 03 STA $03c8 ; button pressed flag ,8767 8d c9 03 STA $03c9 ; cursor movement area ,876a 8d cc 03 STA $03cc ,876d a2 3f LDX #$3f ,876f a0 01 LDY #$01 ,8771 8e ca 03 STX $03ca ,8774 8c cb 03 STY $03cb ,8777 a2 c7 LDX #$c7 ,8779 8e cd 03 STX $03cd ,877c 78 SEI ,877d a2 21 LDX #$21 ; install interrupt vector ,877f a0 de LDY #$de ,8781 8e 14 03 STX $0314 ,8784 20 e0 de JSR $dee0 ; patch - disable std. irq timer ,8787 ad 1a d0 LDA $d01a ; enable raster interrupt ,878a 09 01 ORA #$01 ,878c 8d 1a d0 STA $d01a ,878f a9 25 LDA #$25 ; set interrupt raster line to $25 ,8791 8d c0 03 STA $03c0 ,8794 8d 12 d0 STA $d012 ,8797 ad 11 d0 LDA $d011 ; MSB of interrupt raster line = 0 ,879a 29 7f AND #$7f ,879c 8d 11 d0 STA $d011 ,879f 58 CLI ,87a0 60 RTS # call #12 - DISABLE POINTER AND POINTER INTERRUPTS ] descr: ] Disable cursor sprites ] Restore default interrupt vector ] Disable raster interrupt ] output: ] $0314,$0315 = interrupt vector >87a1 ; -- disable pointer ,87a1 78 SEI ,87a2 ad 1a d0 LDA $d01a ; disable raster interrupts ,87a5 29 fe AND #$fe ,87a7 8d 1a d0 STA $d01a ,87aa a9 00 LDA #$00 ; disable sprites ,87ac 8d 15 d0 STA $d015 ,87af a2 31 LDX #$31 ; restore default interrupt vector ,87b1 a0 ea LDY #$ea ,87b3 8e 14 03 STX $0314 ,87b6 20 ec de JSR $deec ; patch - enable std. irq timer ,87b9 58 CLI ,87ba 60 RTS >87bb ; -- pointer interrupt service routine ] descr: ] Process events from input device (mouse,joystick or keyboard) ] Update cursor position and button pressed flag ] note: ] Executed twice each screen refresh frame ] input: ] $bd = input device configuration ] bits 2-3: acceleration ] bits 4-5: speed ] bit 6: mouse/joystick (1 = mouse) ] bit 7: port 1/port 2 (1 = port 2) ] uses: ] $03c0 = interrupt raster line ] $03c3 = pointer acceleration ] $03d1 = text cursor blinking delay ] $03d2 = text cursor blinking color ] calls: ] $89c5 = process joystick events ] $8a52 = process mouse events ] $8b1b = move pointer ] output: ] x = don't call kernel irq routine ,87bb ad 19 d0 LDA $d019 ; raster or clock ,87be 29 01 AND #$01 ,87c0 f0 69 BEQ $882b ; jump to clock interrupt service ,87c2 8d 19 d0 STA $d019 ,87c5 ad c0 03 LDA $03c0 ; alternate interrupt raster line ,87c8 49 d0 EOR #$d0 ; interrupt lines $25 and $f5 ,87ca 8d c0 03 STA $03c0 ,87cd 8d 12 d0 STA $d012 ,87d0 ad 11 d0 LDA $d011 ,87d3 29 7f AND #$7f ,87d5 8d 11 d0 STA $d011 ,87d8 ce d1 03 DEC $03d1 ; text cursor blinking ,87db d0 18 BNE $87f5 ,87dd a9 08 LDA #$08 ,87df 8d d1 03 STA $03d1 ; blinking delay ,87e2 ac d2 03 LDY $03d2 ; color number ,87e5 b9 21 88 LDA $8821,Y ,87e8 8d 2d d0 STA $d02d ; sprite 6 color ,87eb ce d2 03 DEC $03d2 ,87ee 10 05 BPL $87f5 ,87f0 a9 09 LDA #$09 ,87f2 8d d2 03 STA $03d2 ,87f5 a5 bd LDA $bd ,87f7 4a LSR ,87f8 4a LSR ,87f9 29 03 AND #$03 ; pointer acceleration ,87fb a8 TAY ,87fc b9 bf 89 LDA $89bf,Y ; acceleration table for joystick ,87ff 24 bd BIT $bd ,8801 50 03 BVC $8806 ,8803 b9 c2 89 LDA $89c2,Y ; acceleration table for mouse ,8806 8d c3 03 STA $03c3 ,8809 a0 00 LDY #$00 ,880b 24 bd BIT $bd ,880d 30 01 BMI $8810 ,880f c8 INY ; port 1 ,8810 70 06 BVS $8818 ,8812 20 c5 89 JSR $89c5 ; process joystick events ,8815 18 CLC ,8816 90 03 BCC $881b ,8818 20 52 8a JSR $8a52 ; process mouse events ,881b 20 1b 8b JSR $8b1b ; move pointer ,881e 4c 00 df JMP $df00 ; patch - process clock interrupt ($882b) every screen retrace >8821 ; -- colors for text cursor blinking :8821 00 0b 0c 0f 01 01 0f 0c :8829 0b 00 >882b ; -- keyboard interrupt service routine ] descr: ] Reset computer if user pressed CTRL+RSHIFT+LSHIFT combination ] Update TOD clock blinking dots ] Trigger TOD clock alarm ] Process extended Commodore 128 keyboard ] note: ] In older versions executed every irq timer underflow ] In newer versions (irq timer is disabled) executed once per frame ] input: ] $be = desktop flags ] bit 3: disable numeric keyboard ] bit 6: clock alarm enabled ] bit 7: clock displayed ] uses: ] $02,$cb,$c5,$f5,$f6 ] calls: ] $8d5f = wait for raster retrace ] $8973 = clock alarm ] $eae0 = decode key and insert into keyboard buffer ] output: ] x = don't call kernel irq routine ,882b a9 7f LDA #$7f ,882d 8d 00 dc STA $dc00 ,8830 ad 01 dc LDA $dc01 ; reset if user pressed CTRL+RSHIFT+LSHIFT ,8833 c9 fb CMP #$fb ,8835 d0 2b BNE $8862 ,8837 a9 bf LDA #$bf ,8839 8d 00 dc STA $dc00 ,883c ad 01 dc LDA $dc01 ,883f c9 ef CMP #$ef ,8841 d0 1f BNE $8862 ,8843 a9 fd LDA #$fd ,8845 8d 00 dc STA $dc00 ,8848 ad 01 dc LDA $dc01 ,884b c9 7f CMP #$7f ,884d d0 13 BNE $8862 ,884f 20 5f 8d JSR $8d5f ; wait for retrace ,8852 a9 0b LDA #$0b ; blank screen ,8854 8d 11 d0 STA $d011 ,8857 a9 fc LDA #$fc ,8859 48 PHA ,885a a9 e1 LDA #$e1 ,885c 48 PHA ,885d a9 40 LDA #$40 ,885f 4c 01 de JMP $de01 ; switch to ROM 0, JMP $FCE2 ,8862 a5 be LDA $be ; clock displayed? ,8864 29 80 AND #$80 ,8866 f0 66 BEQ $88ce ,8868 ad 09 dc LDA $dc09 ; even or odd second ,886b 29 01 AND #$01 ,886d d0 31 BNE $88a0 ,886f ad 1b 21 LDA $211b ; show clock dots ,8872 29 08 AND #$08 ,8874 f0 27 BEQ $889d ,8876 ad 1b 41 LDA $411b ,8879 29 08 AND #$08 ,887b f0 20 BEQ $889d ,887d ad 1b 21 LDA $211b ,8880 29 f7 AND #$f7 ,8882 8d 1b 21 STA $211b ,8885 ad 1e 21 LDA $211e ,8888 29 f7 AND #$f7 ,888a 8d 1e 21 STA $211e ,888d ad 1b 41 LDA $411b ,8890 29 f7 AND #$f7 ,8892 8d 1b 41 STA $411b ,8895 ad 1e 41 LDA $411e ,8898 29 f7 AND #$f7 ,889a 8d 1e 41 STA $411e ,889d 4c ce 88 JMP $88ce ,88a0 ad 1b 21 LDA $211b ,88a3 29 08 AND #$08 ,88a5 d0 27 BNE $88ce ,88a7 ad 1b 41 LDA $411b ,88aa 29 08 AND #$08 ,88ac d0 20 BNE $88ce ,88ae ad 1b 21 LDA $211b ; hide clock dots ,88b1 09 08 ORA #$08 ,88b3 8d 1b 21 STA $211b ,88b6 ad 1e 21 LDA $211e ,88b9 09 08 ORA #$08 ,88bb 8d 1e 21 STA $211e ,88be ad 1b 41 LDA $411b ,88c1 09 08 ORA #$08 ,88c3 8d 1b 41 STA $411b ,88c6 ad 1e 41 LDA $411e ,88c9 09 08 ORA #$08 ,88cb 8d 1e 41 STA $411e ,88ce ad 0d dc LDA $dc0d ; test clock alarm ,88d1 29 04 AND #$04 ,88d3 f0 0f BEQ $88e4 ,88d5 a5 be LDA $be ; alarm on? ,88d7 29 40 AND #$40 ,88d9 f0 09 BEQ $88e4 ,88db a5 be LDA $be ; disable alarm (why?) ,88dd 29 bf AND #$bf ,88df 85 be STA $be ,88e1 20 73 89 JSR $8973 ; clock alarm ,88e4 a0 ff LDY #$ff ,88e6 8c 00 dc STY $dc00 ; deactivate keyboard lines ,88e9 ad 01 dc LDA $dc01 ; any signal from joystick port 1 active? ,88ec 29 1f AND #$1f ,88ee 49 1f EOR #$1f ,88f0 f0 06 BEQ $88f8 ; no - process keyboard ,88f2 a2 01 LDX #$01 ; don't call kernel irq routine on exit ,88f4 ad 0d dc LDA $dc0d ; reset CIA1 irq latch ,88f7 60 RTS ,88f8 a5 be LDA $be ; C128 keyboard enabled ,88fa 29 08 AND #$08 ,88fc d0 11 BNE $890f ,88fe c8 INY ,88ff 8c 2f d0 STY $d02f ; activate extended keyboard lines ,8902 ad 01 dc LDA $dc01 ; any key pressed? ,8905 c9 ff CMP #$ff ,8907 d0 0c BNE $8915 ; process extended keyboard events ,8909 88 DEY ,890a 8c 2f d0 STY $d02f ; deactivate extended keyboard lines ,890d e6 02 INC $02 ,890f 20 42 eb JSR $eb42 ; (LDA #$7f STA $dc00) ,8912 4c 57 89 JMP $8957 ; leave handler, call kernel irq >8915 ; -- process extended C128 keyboard events ,8915 a9 18 LDA #$18 ,8917 85 cb STA $cb ; key index - no key pressed ,8919 a5 02 LDA $02 ; restore last key pressed ,891b 85 c5 STA $c5 ,891d a9 fe LDA #$fe ; first line ,891f 8d 2f d0 STA $d02f ; activate extended keyboard line ,8922 48 PHA ,8923 a9 5a LDA #$5a ; pointer to extended keyboard table ,8925 85 f5 STA $f5 ,8927 a9 89 LDA #$89 ,8929 85 f6 STA $f6 ,892b a2 08 LDX #$08 ,892d ad 01 dc LDA $dc01 ; read input lines ,8930 cd 01 dc CMP $dc01 ,8933 d0 f8 BNE $892d ,8935 4a LSR ,8936 b0 02 BCS $893a ,8938 84 cb STY $cb ; key pressed - save key index ,893a c8 INY ,893b c0 19 CPY #$19 ,893d b0 0b BCS $894a ; all keys tested ,893f ca DEX ; test next input line ,8940 d0 f3 BNE $8935 ,8942 38 SEC ,8943 68 PLA ,8944 2a ROL ,8945 8d 2f d0 STA $d02f ; activate next keyboard output line ,8948 d0 d8 BNE $8922 ,894a 68 PLA ,894b 20 e0 ea JSR $eae0 ; decode key and insert into buffer ,894e a9 ff LDA #$ff ,8950 8d 2f d0 STA $d02f ; deactivate extended keyboard lines ,8953 a5 c5 LDA $c5 ; save last key pressed ,8955 85 02 STA $02 ,8957 a2 00 LDX #$00 ; call kernel irq routine on exit ,8959 60 RTS >895a ; -- extended keyboard table :895a 93 38 35 24 32 34 37 31 :8962 23 2b 2d 8d 0d 36 39 33 :896a 3f 30 2e 91 11 9d 1d ff :8972 ff >8973 ; -- clock alarm ] descr: ] Play sounds and highlight border until any key is pressed ] uses: ] $02 ,8973 ee 20 d0 INC $d020 ,8976 a9 ff LDA #$ff ,8978 85 02 STA $02 ,897a a9 00 LDA #$00 ,897c 8d 00 dc STA $dc00 ,897f 8d 05 d4 STA $d405 ,8982 a2 f0 LDX #$f0 ,8984 8e 06 d4 STX $d406 ,8987 a2 0f LDX #$0f ,8989 8e 18 d4 STX $d418 ,898c a2 21 LDX #$21 ,898e 8e 04 d4 STX $d404 ,8991 aa TAX ,8992 a8 TAY ,8993 8e 00 d4 STX $d400 ,8996 8c 01 d4 STY $d401 ,8999 e8 INX ,899a d0 f7 BNE $8993 ,899c a5 02 LDA $02 ,899e f0 04 BEQ $89a4 ,89a0 c6 02 DEC $02 ,89a2 d0 07 BNE $89ab ,89a4 ad 01 dc LDA $dc01 ,89a7 c9 ff CMP #$ff ,89a9 d0 07 BNE $89b2 ,89ab c8 INY ,89ac c0 af CPY #$af ,89ae d0 e3 BNE $8993 ,89b0 f0 c8 BEQ $897a ,89b2 8e 18 d4 STX $d418 ,89b5 8e 00 d4 STX $d400 ,89b8 8e 01 d4 STX $d401 ,89bb ce 20 d0 DEC $d020 ,89be 60 RTS >89bf ; -- pointer acceleration tables :89bf 14 0a 05 04 03 02 >89c5 ; -- joystick handler (y = port number) ] descr: ] Read joystick state and update button pressed flags ] and pointer movement registers ] input: ] y = port number ] $c5 = key code from kernel ] $028d = shift keys from kernel ] $03c1 = pointer velocity ] $03c3 = pointer acceleration ] uses: ] $03c2 = acceleration counter ] output: ] $03c6 = horizontal pointer movement ] $03c7 = vertical pointer movement ] $03c8 = button pressed flag ,89c5 a2 ff LDX #$ff ; disable keyboard lines ,89c7 8e 00 dc STX $dc00 ,89ca e8 INX ,89cb 8e c7 03 STX $03c7 ,89ce 8e c6 03 STX $03c6 ,89d1 a5 c5 LDA $c5 ; simulate joystick with function keys ,89d3 c9 07 CMP #$07 ,89d5 b0 1c BCS $89f3 ,89d7 c9 04 CMP #$04 ,89d9 d0 03 BNE $89de ,89db ee c7 03 INC $03c7 ; f1 up ,89de c9 05 CMP #$05 ,89e0 d0 03 BNE $89e5 ,89e2 ce c7 03 DEC $03c7 ; f3 down ,89e5 c9 06 CMP #$06 ,89e7 d0 03 BNE $89ec ,89e9 ee c6 03 INC $03c6 ; f5 left ,89ec c9 03 CMP #$03 ,89ee d0 03 BNE $89f3 ,89f0 ce c6 03 DEC $03c6 ; f7 right ,89f3 b9 00 dc LDA $dc00,Y ; read joystick port ,89f6 4a LSR ,89f7 b0 03 BCS $89fc ,89f9 ee c7 03 INC $03c7 ,89fc 4a LSR ,89fd b0 03 BCS $8a02 ,89ff ce c7 03 DEC $03c7 ,8a02 4a LSR ,8a03 b0 03 BCS $8a08 ,8a05 ee c6 03 INC $03c6 ,8a08 4a LSR ,8a09 b0 03 BCS $8a0e ,8a0b ce c6 03 DEC $03c6 ,8a0e 29 01 AND #$01 ; fire ,8a10 8d c8 03 STA $03c8 ,8a13 ad 8d 02 LDA $028d ; fire with CBM ,8a16 29 02 AND #$02 ,8a18 f0 03 BEQ $8a1d ,8a1a 8e c8 03 STX $03c8 ,8a1d ae c1 03 LDX $03c1 ; pointer velocity ,8a20 f0 11 BEQ $8a33 ,8a22 ad c2 03 LDA $03c2 ,8a25 cd c3 03 CMP $03c3 ; pointer acceleration ,8a28 90 09 BCC $8a33 ,8a2a 0e c7 03 ASL $03c7 ; pointer movement * 2 ,8a2d 0e c6 03 ASL $03c6 ,8a30 ca DEX ,8a31 d0 f7 BNE $8a2a ,8a33 a5 c5 LDA $c5 ,8a35 c9 07 CMP #$07 ,8a37 90 09 BCC $8a42 ; function key pressed ,8a39 b9 00 dc LDA $dc00,Y ; any direction active ,8a3c 49 ff EOR #$ff ,8a3e 29 0f AND #$0f ,8a40 f0 0c BEQ $8a4e ,8a42 ee c2 03 INC $03c2 ; trigger acceleration ,8a45 ad c2 03 LDA $03c2 ,8a48 c9 80 CMP #$80 ,8a4a 90 02 BCC $8a4e ,8a4c a9 78 LDA #$78 ,8a4e 8d c2 03 STA $03c2 ,8a51 60 RTS >8a52 ; -- mouse handler (y = port number, ignored) ] descr: ] Process 1351 mouse events, update button pressed flag ] and pointer movement registers ] note: ] Older versions of FCIII support NEOS mouse instead. ] input: ] $c5 = key code from kernel ] $028d = shift keys from kernel ] $03c1 = pointer velocity ] uses: ] $03d3,$03d4,$03d5,$03d6 ] output: ] $03c6 = horizontal pointer movement ] $03c7 = vertical pointer movement ] $03c8 = button pressed flag ,8a52 a2 00 LDX #$00 ,8a54 a9 ff LDA #$ff ,8a56 8d 00 dc STA $dc00 ; disable keyboard output lines, activate both mouse ports ,8a59 ad 00 dc LDA $dc00 ,8a5c 2d 01 dc AND $dc01 ; read button pin on both lines ,8a5f 29 10 AND #$10 ,8a61 f0 08 BEQ $8a6b ; button pressed ,8a63 ad 8d 02 LDA $028d ,8a66 29 02 AND #$02 ,8a68 d0 01 BNE $8a6b ; simulate button with C= key ,8a6a e8 INX ,8a6b 8e c8 03 STX $03c8 ; save button pressed flag ,8a6e a5 c5 LDA $c5 ; last key pressed ,8a70 c9 07 CMP #$07 ; function key (actually RET or DEL will also trigger) ,8a72 b0 03 BCS $8a77 ,8a74 4c c5 89 JMP $89c5 ; use joystick handler to process function keys ,8a77 ad 19 d4 LDA $d419 ; A/D converter 1 ,8a7a ac d3 03 LDY $03d3 ; previous value ,8a7d 20 bb 8a JSR $8abb ; calculate difference ,8a80 49 ff EOR #$ff ,8a82 8d c6 03 STA $03c6 ; save pointer movement y ,8a85 ee c6 03 INC $03c6 ,8a88 8c d3 03 STY $03d3 ; save A/D converter value ,8a8b ad 1a d4 LDA $d41a ; A/D converter 2 ,8a8e ac d4 03 LDY $03d4 ; previous value ,8a91 20 bb 8a JSR $8abb ; calculate difference ,8a94 8d c7 03 STA $03c7 ; save pointer movement x ,8a97 8c d4 03 STY $03d4 ; save A/D converter value ,8a9a ad c1 03 LDA $03c1 ; pointer velocity ,8a9d c9 01 CMP #$01 ,8a9f f0 19 BEQ $8aba ; normal velocity ,8aa1 90 09 BCC $8aac ; low velocity ,8aa3 0e c6 03 ASL $03c6 ; multiply pointer movement * 2 ,8aa6 0e c7 03 ASL $03c7 ,8aa9 4c ba 8a JMP $8aba ,8aac ad c6 03 LDA $03c6 ; divide pointer movement / 2 ,8aaf 0a ASL ,8ab0 6e c6 03 ROR $03c6 ,8ab3 ad c7 03 LDA $03c7 ,8ab6 0a ASL ,8ab7 6e c7 03 ROR $03c7 ,8aba 60 RTS ,8abb 8c d6 03 STY $03d6 ; previous value ,8abe 8d d5 03 STA $03d5 ; current value ,8ac1 a2 00 LDX #$00 ,8ac3 38 SEC ,8ac4 ed d6 03 SBC $03d6 ; difference ,8ac7 29 7f AND #$7f ; limit to 7 bits ,8ac9 c9 40 CMP #$40 ,8acb b0 07 BCS $8ad4 ; positive ,8acd 4a LSR ; divide / 2 ,8ace f0 12 BEQ $8ae2 ; if < 2, ignore movement ,8ad0 ac d5 03 LDY $03d5 ,8ad3 60 RTS ,8ad4 09 c0 ORA #$c0 ; extend negative number ,8ad6 c9 ff CMP #$ff ; if abs() < 2, ignore movement ,8ad8 f0 08 BEQ $8ae2 ,8ada 38 SEC ; divide / 2 ,8adb 6a ROR ,8adc a2 ff LDX #$ff ,8ade ac d5 03 LDY $03d5 ,8ae1 60 RTS ,8ae2 a9 00 LDA #$00 ,8ae4 60 RTS ; -- unused memory :8ae5 ff ff ff ff ff ff ff ff :8aed ff ff ff ff ff ff ff ff :8af5 ff ff ff ff ff ff ff ff :8afd ff ff ff ff ff ff ff ff :8b05 ff ff ff ff ff ff ff ff :8b0d ff ff ff ff ff ff ff ff :8b15 ff ff ff ff ff ff ;; NOV 1987 ; -- NEOS mouse handler ;;,8a52 ad 00 dc LDA $dc00 ;;,8a55 48 PHA ;;,8a56 ad 01 dc LDA $dc01 ;;,8a59 48 PHA ;;,8a5a ad 02 dc LDA $dc02 ;;,8a5d 48 PHA ;;,8a5e ad 03 dc LDA $dc03 ;;,8a61 48 PHA ;;,8a62 a9 10 LDA #$10 ;;,8a64 99 02 dc STA $dc02,Y ; set line 5 to output, other lines to input ;;,8a67 b9 00 dc LDA $dc00,Y ; activate line 5 (fire pin) ;;,8a6a 29 ef AND #$ef ;;,8a6c 99 00 dc STA $dc00,Y ;;,8a6f a2 08 LDX #$08 ; delay 8 ;;,8a71 20 c6 8b JSR $8bc6 ;;,8a74 b9 00 dc LDA $dc00,Y ; read horizontal movement, high nybble ;;,8a77 0a ASL ;;,8a78 0a ASL ;;,8a79 0a ASL ;;,8a7a 0a ASL ;;,8a7b 8d c6 03 STA $03c6 ;;,8a7e b9 00 dc LDA $dc00,Y ; deactivate line 5 ;;,8a81 09 10 ORA #$10 ;;,8a83 99 00 dc STA $dc00,Y ;;,8a86 a2 05 LDX #$05 ; delay 5 ;;,8a88 20 c6 8b JSR $8bc6 ;;,8a8b b9 00 dc LDA $dc00,Y ; read low nybble ;;,8a8e 29 0f AND #$0f ;;,8a90 0d c6 03 ORA $03c6 ;;,8a93 8d c6 03 STA $03c6 ;;,8a96 b9 00 dc LDA $dc00,Y ; activate line 5 ;;,8a99 29 ef AND #$ef ;;,8a9b 99 00 dc STA $dc00,Y ;;,8a9e a2 05 LDX #$05 ; delay 5 ;;,8aa0 20 c6 8b JSR $8bc6 ;;,8aa3 b9 00 dc LDA $dc00,Y ; vertical movement, high nybble ;;,8aa6 0a ASL ;;,8aa7 0a ASL ;;,8aa8 0a ASL ;;,8aa9 0a ASL ;;,8aaa 8d c7 03 STA $03c7 ;;,8aad b9 00 dc LDA $dc00,Y ; deactivate line 5 ;;,8ab0 09 10 ORA #$10 ;;,8ab2 99 00 dc STA $dc00,Y ;;,8ab5 a2 05 LDX #$05 ; delay 5 ;;,8ab7 20 c6 8b JSR $8bc6 ;;,8aba b9 00 dc LDA $dc00,Y ; low nybble ;;,8abd 29 0f AND #$0f ;;,8abf 0d c7 03 ORA $03c7 ;;,8ac2 8d c7 03 STA $03c7 ;;,8ac5 a2 00 LDX #$00 ; read button ;;,8ac7 ad 19 d4 LDA $d419 ;;,8aca c9 ff CMP #$ff ;;,8acc f0 01 BEQ $8acf ;;,8ace e8 INX ;;,8acf 8e c8 03 STX $03c8 ;;,8ad2 68 PLA ;;,8ad3 8d 03 dc STA $dc03 ;;,8ad6 68 PLA ;;,8ad7 8d 02 dc STA $dc02 ;;,8ada 68 PLA ;;,8adb 8d 01 dc STA $dc01 ;;,8ade 68 PLA ;;,8adf 8d 00 dc STA $dc00 ;;,8ae2 ae c1 03 LDX $03c1 ; acceleration ;;,8ae5 f0 33 BEQ $8b1a ;;,8ae7 ad c7 03 LDA $03c7 ;;,8aea 2c c7 03 BIT $03c7 ;;,8aed 10 05 BPL $8af4 ;;,8aef 49 ff EOR #$ff ;;,8af1 18 CLC ;;,8af2 69 01 ADC #$01 ;;,8af4 cd c3 03 CMP $03c3 ;;,8af7 90 06 BCC $8aff ;;,8af9 0e c7 03 ASL $03c7 ;;,8afc ca DEX ;;,8afd d0 fa BNE $8af9 ;;,8aff ad c6 03 LDA $03c6 ;;,8b02 2c c6 03 BIT $03c6 ;;,8b05 10 05 BPL $8b0c ;;,8b07 49 ff EOR #$ff ;;,8b09 18 CLC ;;,8b0a 69 01 ADC #$01 ;;,8b0c cd c3 03 CMP $03c3 ;;,8b0f 90 09 BCC $8b1a ;;,8b11 ae c1 03 LDX $03c1 ;;,8b14 0e c6 03 ASL $03c6 ;;,8b17 ca DEX ;;,8b18 d0 fa BNE $8b14 ;;,8b1a 60 RTS >8b1b ; -- move pointer ] descr: ] Limit pointer movement to pointer movement area ] Update pointer position ] Update pointer sprite position ] input: ] $b4,$b5 = pointer position x ] $b6 = pointer position y ] $03c6 = horizontal movement ] $03c7 = vertical movement ] $03c9 = movement area - left edge ] $03ca,$03cb = movement area - right edge ] $03cc = movement area - top edge ] $03cd = movement area - bottom edge ] output: ] $b4-$b6 = new pointer position ,8b1b ad c7 03 LDA $03c7 ; vertical ,8b1e 0a ASL ,8b1f b0 13 BCS $8b34 ,8b21 38 SEC ; move up ,8b22 a5 b6 LDA $b6 ,8b24 ed c7 03 SBC $03c7 ,8b27 90 05 BCC $8b2e ,8b29 cd cc 03 CMP $03cc ; test cursor area edge ,8b2c b0 15 BCS $8b43 ,8b2e ad cc 03 LDA $03cc ,8b31 18 CLC ,8b32 90 0f BCC $8b43 ,8b34 a5 b6 LDA $b6 ; move down ,8b36 ed c7 03 SBC $03c7 ,8b39 b0 05 BCS $8b40 ,8b3b cd cd 03 CMP $03cd ; test cursor area edge ,8b3e 90 03 BCC $8b43 ,8b40 ad cd 03 LDA $03cd ,8b43 85 b6 STA $b6 ,8b45 a6 b5 LDX $b5 ; horizontal ,8b47 ad c6 03 LDA $03c6 ,8b4a 0a ASL ,8b4b b0 23 BCS $8b70 ,8b4d 38 SEC ; move left ,8b4e a5 b4 LDA $b4 ,8b50 ed c6 03 SBC $03c6 ,8b53 90 0f BCC $8b64 ,8b55 e0 00 CPX #$00 ,8b57 d0 37 BNE $8b90 ,8b59 cd c9 03 CMP $03c9 ; test cursor area edge ,8b5c b0 32 BCS $8b90 ,8b5e ad c9 03 LDA $03c9 ,8b61 38 SEC ,8b62 b0 2c BCS $8b90 ,8b64 e0 00 CPX #$00 ,8b66 f0 04 BEQ $8b6c ,8b68 a2 00 LDX #$00 ,8b6a f0 24 BEQ $8b90 ,8b6c a9 00 LDA #$00 ,8b6e f0 20 BEQ $8b90 ,8b70 a5 b4 LDA $b4 ; move right ,8b72 ed c6 03 SBC $03c6 ,8b75 b0 0c BCS $8b83 ,8b77 ec cb 03 CPX $03cb ; test cursor area edge ,8b7a d0 14 BNE $8b90 ,8b7c cd ca 03 CMP $03ca ,8b7f 90 0f BCC $8b90 ,8b81 b0 0a BCS $8b8d ,8b83 ec cb 03 CPX $03cb ,8b86 f0 05 BEQ $8b8d ,8b88 ae cb 03 LDX $03cb ,8b8b d0 ef BNE $8b7c ,8b8d ad ca 03 LDA $03ca ,8b90 85 b4 STA $b4 ,8b92 86 b5 STX $b5 ,8b94 18 CLC ; update sprite position ,8b95 a5 b6 LDA $b6 ,8b97 69 32 ADC #$32 ,8b99 8d 01 d0 STA $d001 ,8b9c 8d 03 d0 STA $d003 ,8b9f a2 00 LDX #$00 ,8ba1 a5 b5 LDA $b5 ,8ba3 f0 02 BEQ $8ba7 ,8ba5 a2 03 LDX #$03 ,8ba7 18 CLC ,8ba8 a5 b4 LDA $b4 ,8baa 69 18 ADC #$18 ,8bac 8d 00 d0 STA $d000 ,8baf 8d 02 d0 STA $d002 ,8bb2 90 02 BCC $8bb6 ,8bb4 a2 03 LDX #$03 ,8bb6 ad 10 d0 LDA $d010 ,8bb9 29 fc AND #$fc ,8bbb 8d 10 d0 STA $d010 ,8bbe 8a TXA ,8bbf 0d 10 d0 ORA $d010 ,8bc2 8d 10 d0 STA $d010 ,8bc5 60 RTS >8bc6 ; -- unused delay loop for NEOS mouse ,8bc6 ea NOP ,8bc7 ea NOP ,8bc8 ea NOP ,8bc9 ca DEX ,8bca d0 fa BNE $8bc6 ,8bcc 60 RTS # call #13 - DRAG WINDOW >8bcd ; -- drag window ] descr: ] Limit pointer movement so that window can't be dragged ] outside screen area. ] Display edge markers and update their positions as pointer moves ] Wait until user releases button ] Returns new window position ] note: ] This procedure is called when user clicks on window drag bar. ] input: ] $b4-$b6 = cursor position ] $c000,$c001 = window position ] $c002,$c003 = window size ] uses: ] $03c4,$03c5 = cursor - window corner offset ] $03c9-$03cc = cursor movement area ] $c3,$a9,$aa,$f7 ] output: ] x,y = new window position ,8bcd 38 SEC ,8bce a5 b4 LDA $b4 ; pointer position x ,8bd0 ed 00 c0 SBC $c000 ; window position ,8bd3 8d c4 03 STA $03c4 ; save offset ,8bd6 38 SEC ,8bd7 a5 b6 LDA $b6 ; pointer position y ,8bd9 ed 01 c0 SBC $c001 ; window position ,8bdc 8d c5 03 STA $03c5 ; save offset ,8bdf ae c4 03 LDX $03c4 ,8be2 ad c5 03 LDA $03c5 ,8be5 8e c9 03 STX $03c9 ; limit pointer movement - left ,8be8 18 CLC ,8be9 69 0a ADC #$0a ,8beb 8d cc 03 STA $03cc ; limit pointer movement - top ,8bee 18 CLC ,8bef ad 02 c0 LDA $c002 ; window width ,8bf2 ed c4 03 SBC $03c4 ,8bf5 85 c3 STA $c3 ,8bf7 18 CLC ,8bf8 ad 03 c0 LDA $c003 ; window height ,8bfb ed c5 03 SBC $03c5 ,8bfe 85 f7 STA $f7 ,8c00 18 CLC ,8c01 a2 01 LDX #$01 ,8c03 a9 3f LDA #$3f ,8c05 e5 c3 SBC $c3 ,8c07 8d ca 03 STA $03ca ; limit movement - right ,8c0a b0 01 BCS $8c0d ,8c0c ca DEX ,8c0d 8e cb 03 STX $03cb ,8c10 18 CLC ,8c11 a9 c7 LDA #$c7 ,8c13 e5 f7 SBC $f7 ,8c15 8d cd 03 STA $03cd ; limit movement - bottom ; -- window drag loop ,8c18 a6 b5 LDX $b5 ,8c1a a5 b4 LDA $b4 ,8c1c 38 SEC ,8c1d ed c4 03 SBC $03c4 ,8c20 85 c3 STA $c3 ; new window position x ,8c22 b0 01 BCS $8c25 ,8c24 ca DEX ,8c25 86 f7 STX $f7 ,8c27 38 SEC ,8c28 a5 b6 LDA $b6 ,8c2a ed c5 03 SBC $03c5 ,8c2d 85 aa STA $aa ; new window position y ,8c2f a0 00 LDY #$00 ; placement edge markers ,8c31 a6 f7 LDX $f7 ,8c33 18 CLC ,8c34 a5 c3 LDA $c3 ,8c36 69 18 ADC #$18 ,8c38 90 01 BCC $8c3b ,8c3a e8 INX ,8c3b 8d 04 d0 STA $d004 ,8c3e 8d 08 d0 STA $d008 ,8c41 8a TXA ,8c42 f0 04 BEQ $8c48 ,8c44 98 TYA ,8c45 09 14 ORA #$14 ,8c47 a8 TAY ,8c48 18 CLC ,8c49 a5 aa LDA $aa ,8c4b 69 32 ADC #$32 ,8c4d 8d 05 d0 STA $d005 ,8c50 8d 07 d0 STA $d007 ,8c53 a6 f7 LDX $f7 ,8c55 18 CLC ,8c56 a5 c3 LDA $c3 ,8c58 6d 02 c0 ADC $c002 ,8c5b 90 01 BCC $8c5e ,8c5d e8 INX ,8c5e 18 CLC ,8c5f 69 11 ADC #$11 ,8c61 90 01 BCC $8c64 ,8c63 e8 INX ,8c64 8d 06 d0 STA $d006 ,8c67 8d 0a d0 STA $d00a ,8c6a 8a TXA ,8c6b f0 04 BEQ $8c71 ,8c6d 98 TYA ,8c6e 09 28 ORA #$28 ,8c70 a8 TAY ,8c71 18 CLC ,8c72 a5 aa LDA $aa ,8c74 6d 03 c0 ADC $c003 ,8c77 18 CLC ,8c78 69 2c ADC #$2c ,8c7a 8d 09 d0 STA $d009 ,8c7d 8d 0b d0 STA $d00b ,8c80 84 a9 STY $a9 ,8c82 ad 10 d0 LDA $d010 ,8c85 29 03 AND #$03 ,8c87 05 a9 ORA $a9 ,8c89 8d 10 d0 STA $d010 ,8c8c a9 3f LDA #$3f ; enable edge marker sprites ,8c8e 8d 15 d0 STA $d015 ,8c91 ad c8 03 LDA $03c8 ,8c94 f0 82 BEQ $8c18 ; loop until button released ,8c96 a9 00 LDA #$00 ; reset movement area ,8c98 8d c9 03 STA $03c9 ,8c9b 8d cc 03 STA $03cc ,8c9e a2 3f LDX #$3f ,8ca0 a0 01 LDY #$01 ,8ca2 8e ca 03 STX $03ca ,8ca5 8c cb 03 STY $03cb ,8ca8 a2 c7 LDX #$c7 ,8caa 8e cd 03 STX $03cd ,8cad a9 03 LDA #$03 ; disable edge markers ,8caf 8d 15 d0 STA $d015 ,8cb2 a6 c3 LDX $c3 ; validate new position ,8cb4 18 CLC ,8cb5 ad 02 c0 LDA $c002 ,8cb8 65 c3 ADC $c3 ,8cba 90 06 BCC $8cc2 ,8cbc c9 40 CMP #$40 ,8cbe 90 02 BCC $8cc2 ,8cc0 a2 00 LDX #$00 ,8cc2 a4 aa LDY $aa ,8cc4 18 CLC ,8cc5 ad 03 c0 LDA $c003 ,8cc8 65 aa ADC $aa ,8cca c9 c8 CMP #$c8 ,8ccc 90 02 BCC $8cd0 ,8cce a0 0a LDY #$0a ,8cd0 60 RTS >8cd1 ; -- initialize vectors ] descr: ] Disable NMI handler (point to RTI instruction) ] Initialize snapshot image heap pointer ] Clear configuration flags ] Enable screen buffer swapping ] Initialize $de05 indirect jump ($0334-$0336) ] Initialize window procedure vector ] Clear TOD clock alarm ] Place MG87 marker ] Initialize BASIC border color and BASIC flags ] calls: ] $8dfe = clear TOD alarm ] output: ] $c021,$c022 = snapshot image heap pointer - set to $6600 ] $0334-$0336 = $de05 indirect jump vector ] $0337-$0339 = active window procedure vector ] $033a-$033c = auxillary vector ] $c01e = border color in BASIC ] $c01f = BASIC flags ,8cd1 a2 c1 LDX #$c1 ; disable NMI handler ,8cd3 8e 18 03 STX $0318 ,8cd6 a2 00 LDX #$00 ; initialize image heap ,8cd8 a0 66 LDY #$66 ,8cda 8e 21 c0 STX $c021 ,8cdd 8c 22 c0 STY $c022 ,8ce0 86 bd STX $bd ; clear configuration flags ,8ce2 8e d0 03 STX $03d0 ; enable double buffering ,8ce5 8e 23 c0 STX $c023 ; clear windows list ,8ce8 86 be STX $be ,8cea a9 6c LDA #$6c ; initialize indirect jumps ,8cec a0 80 LDY #$80 ,8cee 8d 34 03 STA $0334 ,8cf1 8e 35 03 STX $0335 ,8cf4 8c 36 03 STY $0336 ,8cf7 a9 4c LDA #$4c ,8cf9 8d 37 03 STA $0337 ,8cfc 8e 38 03 STX $0338 ,8cff 8e 39 03 STX $0339 ,8d02 8d 3a 03 STA $033a ,8d05 a9 20 LDA #$20 ; set screen page ,8d07 85 92 STA $92 ,8d09 20 73 de JSR $de73 ; patch - clear TOD alarm and check "MG87" marker ;; SEP 1987 ;;,8d09 20 fe 8d JSR $8dfe ; clear TOD alarm ,8d0c a0 03 LDY #$03 ; place marker "MG87" at $cffc ,8d0e b9 22 8d LDA $8d22,Y ,8d11 99 fc cf STA $cffc,Y ,8d14 88 DEY ,8d15 10 f7 BPL $8d0e ,8d17 a9 06 LDA #$06 ; border color in BASIC ,8d19 8d 1e c0 STA $c01e ,8d1c a9 09 LDA #$09 ; BASIC flags ,8d1e 8d 1f c0 STA $c01f ,8d21 60 RTS :8d22 4d 47 38 37 ; magic number "MG87" >8d26 ; -- initialize graphics mode and video memory ] descr: ] Enable bitmap mode ] Clear both screen buffers ] input: ] $92 = page of active drawing screen is expected to be equal $20 ] calls: ] $8d5f = wait for vertical retrace ] $8102 = memory fill ,8d26 20 5f 8d JSR $8d5f ; wait for vertical retrace ,8d29 a9 0b LDA #$0b ; blank screen ,8d2b 8d 11 d0 STA $d011 ,8d2e a2 97 LDX #$97 ; set video base address to $2000 ,8d30 a0 18 LDY #$18 ,8d32 8e 00 dd STX $dd00 ,8d35 8c 18 d0 STY $d018 ,8d38 a9 00 LDA #$00 ; clear both screen buffers ,8d3a a4 92 LDY $92 ,8d3c a2 40 LDX #$40 ,8d3e 20 02 81 JSR $8102 ,8d41 20 5f 8d JSR $8d5f ; wait for vertical retrace ,8d44 a9 3b LDA #$3b ,8d46 8d 11 d0 STA $d011 ; enable screen and graphics mode ,8d49 60 RTS >8d4a ; -- switch to text mode ] descr: ] Switch to text mode ,8d4a a9 1b LDA #$1b ,8d4c a2 97 LDX #$97 ,8d4e a0 15 LDY #$15 ,8d50 8d 11 d0 STA $d011 ,8d53 8e 00 dd STX $dd00 ,8d56 8c 18 d0 STY $d018 ,8d59 a9 04 LDA #$04 ,8d5b 8d 88 02 STA $0288 ,8d5e 60 RTS >8d5f ; -- wait for vertical retrace ] descr: ] Wait for vertical retrace ,8d5f 78 SEI ,8d60 ad 12 d0 LDA $d012 ,8d63 c9 fb CMP #$fb ,8d65 90 f9 BCC $8d60 ,8d67 58 CLI ,8d68 60 RTS # call #18 - BYTE MULTIPLY >8d69 ; -- byte multiply (x,y) -> ($a3,$a4) ] descr: ] Multiply two unsigned 8 bit values ] input: ] x,y ] uses: ] $a5 ] output: ] $a3,$a4 = result ,8d69 86 a4 STX $a4 ,8d6b 84 a5 STY $a5 ,8d6d a9 00 LDA #$00 ,8d6f 85 a3 STA $a3 ,8d71 a2 08 LDX #$08 ,8d73 46 a4 LSR $a4 ,8d75 90 03 BCC $8d7a ,8d77 18 CLC ,8d78 65 a5 ADC $a5 ,8d7a 6a ROR ,8d7b 66 a3 ROR $a3 ,8d7d ca DEX ,8d7e d0 f3 BNE $8d73 ,8d80 85 a4 STA $a4 ,8d82 60 RTS # call #16 - SET DEFAULT COLORS AND PREFERENCES >8d83 ; -- set default colors and preferences ] descr: ] Set colors and preferences to default values ] output: ] $bd = pointer configuration ] $c017 = pointer color 1 ] $c018 = pointer color 2 ] $c019 = foreground color ] $c01a = background color ] $c01b = joystick/mouse and port number flags ] $c01c = cursor speed ] $03c1 = cursor speed ] $c01d = cursor acceleration ,8d83 a0 07 LDY #$07 ; copy settings from table ,8d85 b9 f6 8d LDA $8df6,Y ,8d88 99 16 c0 STA $c016,Y ,8d8b 88 DEY ,8d8c d0 f7 BNE $8d85 # call #17 - UPDATE SCREEN COLORS AND PREFERENCES >8d8e ; -- update screen colors and preferences ] descr: ] Apply screen colors and preferences ] input: ] $c017 = pointer color 1 ] $c018 = pointer color 2 ] $c019 = foreground color ] $c01a = background color ] $c01b = joystick/mouse and port number flags ] $c01c = cursor speed ] $c01d = cursor acceleration ] output: ] $bd = cursor configuration ] $03c1 = cursor speed ,8d8e a5 bd LDA $bd ; set input device and port number ,8d90 29 3f AND #$3f ,8d92 0d 1b c0 ORA $c01b ,8d95 85 bd STA $bd # call #1b - REFRESH SCREEN COLORS >8d97 ; -- update screen colors ] descr: ] Apply screen colors and preferences, don't change input device and port ] input: ] $c017 = pointer color 1 ] $c018 = pointer color 2 ] $c019 = foreground color ] $c01a = background color ] $c01c = cursor speed ] $c01d = cursor acceleration ] output: ] $bd = cursor configuration ] $03c1 = cursor speed ,8d97 ad 19 c0 LDA $c019 ; foreground color ,8d9a 0a ASL ,8d9b 0a ASL ,8d9c 0a ASL ,8d9d 0a ASL ,8d9e 0d 1a c0 ORA $c01a ; background color ,8da1 a0 00 LDY #$00 ; fill color memory ,8da3 99 00 04 STA $0400,Y ,8da6 99 00 05 STA $0500,Y ,8da9 99 00 06 STA $0600,Y ,8dac 99 f8 06 STA $06f8,Y ,8daf 99 00 60 STA $6000,Y ,8db2 99 00 61 STA $6100,Y ,8db5 99 00 62 STA $6200,Y ,8db8 99 f8 62 STA $62f8,Y ,8dbb c8 INY ,8dbc d0 e5 BNE $8da3 ,8dbe ad 1a c0 LDA $c01a ; border ,8dc1 8d 20 d0 STA $d020 ,8dc4 ae 17 c0 LDX $c017 ; sprites ,8dc7 ac 18 c0 LDY $c018 ,8dca 8e 27 d0 STX $d027 ,8dcd 8c 28 d0 STY $d028 ,8dd0 8e 29 d0 STX $d029 ,8dd3 8e 2a d0 STX $d02a ,8dd6 8e 2b d0 STX $d02b ,8dd9 8e 2c d0 STX $d02c ,8ddc 8e 2d d0 STX $d02d ,8ddf a5 bd LDA $bd ,8de1 29 c3 AND #$c3 ,8de3 85 bd STA $bd ,8de5 ad 1c c0 LDA $c01c ; pointer speed and acceleration ,8de8 8d c1 03 STA $03c1 ,8deb 0a ASL ,8dec 0a ASL ,8ded 0d 1d c0 ORA $c01d ,8df0 0a ASL ,8df1 0a ASL ,8df2 05 bd ORA $bd ,8df4 85 bd STA $bd ,8df6 60 RTS >8df7 ; -- default configuration :8df7 03 00 01 06 80 01 01 >8dfe ; -- reset TOD alarm ] descr: ] Select TOD clock PAL/NTSC frequency ] Set TOD clock alarm to 12:00 PM ,8dfe ad a6 02 LDA $02a6 ; PAL/NTSC flag ,8e01 8d 08 dc STA $dc08 ,8e04 f0 08 BEQ $8e0e ,8e06 ad 0e dc LDA $dc0e ; PAL - switch TOD to 50 Hz frequency ,8e09 09 80 ORA #$80 ,8e0b 8d 0e dc STA $dc0e ,8e0e ad 0f dc LDA $dc0f ; switch to alarm access ,8e11 09 80 ORA #$80 ,8e13 8d 0f dc STA $dc0f ,8e16 a0 03 LDY #$03 ; reset alarm ,8e18 b9 2a 8e LDA $8e2a,Y ,8e1b 99 08 dc STA $dc08,Y ,8e1e 88 DEY ,8e1f 10 f7 BPL $8e18 ,8e21 ad 0f dc LDA $dc0f ; switch to clock access ,8e24 29 7f AND #$7f ,8e26 8d 0f dc STA $dc0f ,8e29 60 RTS >8e2a ; -- TOD alarm reset data :8e2a 00 00 00 92 ; 12:00:00 PM # call #14 - SWITCH OUTPUT SCREEN BUFFER >8e2e ; -- switch output screen buffer ] descr: ] Switch output screen buffer between $2000 and $4000 ] input: ] $03d0 = buffer switching disabled ] $92 = old screen buffer address ] output: ] $92 = new screen buffer address ,8e2e ad d0 03 LDA $03d0 ; double bufferring disabled ,8e31 d0 0e BNE $8e41 ,8e33 a5 92 LDA $92 ; alternate screen buffer address between $2000 and $4000 ,8e35 c9 20 CMP #$20 ,8e37 d0 04 BNE $8e3d ,8e39 a9 40 LDA #$40 ,8e3b d0 02 BNE $8e3f ,8e3d a9 20 LDA #$20 ,8e3f 85 92 STA $92 ,8e41 60 RTS # call #15 - SWITCH VISIBLE SCREEN BUFFER >8e42 ; -- switch visible screen buffer ] descr: ] Switch visible screen buffer between $2000 and $4000 ] input: ] $03d0 = buffer switching disabled ,8e42 ad d0 03 LDA $03d0 ; double bufferring disabled ,8e45 d0 27 BNE $8e6e ,8e47 ad 00 dd LDA $dd00 ; read active VIC memory page ,8e4a 29 01 AND #$01 ,8e4c f0 08 BEQ $8e56 ,8e4e a9 3b LDA #$3b ; graphics mode enabled, screen visible ,8e50 a2 96 LDX #$96 ; VIC memory page $4000 ,8e52 a0 80 LDY #$80 ; graphics address +$0000, color address +$2000 ,8e54 d0 06 BNE $8e5c ,8e56 a9 3b LDA #$3b ; graphics mode enabled, screen visible ,8e58 a2 97 LDX #$97 ; VIC memory page $0000 ,8e5a a0 18 LDY #$18 ; graphics address +$2000, color address +$0400 ,8e5c 8d 11 d0 STA $d011 ,8e5f 78 SEI ; wait for vertical retrace ,8e60 ad 12 d0 LDA $d012 ,8e63 c9 fb CMP #$fb ,8e65 90 f9 BCC $8e60 ,8e67 58 CLI ,8e68 8e 00 dd STX $dd00 ,8e6b 8c 18 d0 STY $d018 ,8e6e 60 RTS ,8e6f 85 9f STA $9f ; draw single character - code 0 ,8e71 60 RTS # call #1a - DRAW SINGLE CHARACTER >8e72 ; -- draw character x with attributes y ] descr: ] Display single character on screen ] Update drawing position ] input: ] $fd,$fe,$ff = current drawing position ] y = character spacing and attributes ] bit 0-3: spacing ] bit 4: fixed width ] bit 7: bold ] x = character to draw ] uses: ] $a3 = character spacing and attributes ] $a5,$a6 = screen address ] $a7,$a8 = address of character definition ] $96,$9e,$a4,$a9,$aa,$c3,$f7 ] output: ] $fd,$fe,$ff = new drawing position ] $9f = displayed character width ,8e72 84 a3 STY $a3 # call #19 - DRAW SINGLE CHARACTER >8e74 ; -- draw character x with attributes $a3 ] descr: ] Display single character on screen ] Update drawing position ] input: ] $fd,$fe,$ff = current drawing position ] $a3 = character spacing and attributes ] bit 0-3: spacing ] bit 4: fixed width ] bit 7: bold ] x = character to draw ] uses: ] $a5,$a6 = screen address ] $a7,$a8 = address of character definition ] $96,$9e,$a4,$a9,$aa,$c3,$f7 ] output: ] $fd,$fe,$ff = new drawing position ] $9f = displayed character width ,8e74 18 CLC ,8e75 8a TXA ,8e76 f0 f7 BEQ $8e6f ,8e78 69 92 ADC #$92 ,8e7a 85 a7 STA $a7 ; set address of character definition ,8e7c a0 a1 LDY #$a1 ,8e7e 90 01 BCC $8e81 ,8e80 c8 INY ,8e81 84 a8 STY $a8 ; MSB of address ,8e83 a0 00 LDY #$00 ,8e85 84 f7 STY $f7 ,8e87 a5 fd LDA $fd ; screen position bit number ,8e89 c9 03 CMP #$03 ,8e8b b0 07 BCS $8e94 ,8e8d 85 a9 STA $a9 ; bit number < 3 - rotate left ,8e8f 98 TYA ; $aa = 0 ,8e90 e6 a9 INC $a9 ; $a9 = bit number + 1 ,8e92 d0 04 BNE $8e98 ,8e94 49 07 EOR #$07 ; bit number >= 3 - rotate right ,8e96 84 a9 STY $a9 ; $a9 = 0 ,8e98 85 aa STA $aa ; $aa = 7 - bit number ,8e9a a9 09 LDA #$09 ; characted height = 9 ,8e9c 85 c4 STA $c4 ,8e9e a4 a3 LDY $a3 ; character spacing ,8ea0 10 01 BPL $8ea3 ,8ea2 c8 INY ,8ea3 98 TYA ,8ea4 29 10 AND #$10 ,8ea6 38 SEC ,8ea7 f0 07 BEQ $8eb0 ,8ea9 98 TYA ; fixed width ,8eaa 29 0f AND #$0f ,8eac 69 06 ADC #$06 ; set character width to 6 ,8eae d0 06 BNE $8eb6 ,8eb0 98 TYA ,8eb1 29 0f AND #$0f ,8eb3 7d 79 a5 ADC $a579,X ; add character width ,8eb6 85 9f STA $9f ; save character width ,8eb8 a5 fe LDA $fe ,8eba a4 ff LDY $ff ,8ebc 85 a5 STA $a5 ; copy current position address ,8ebe 84 a6 STY $a6 ,8ec0 a4 fd LDY $fd ; bit number ,8ec2 b9 4d 81 LDA $814d,Y ,8ec5 85 a4 STA $a4 ; left side mask ,8ec7 98 TYA ,8ec8 49 07 EOR #$07 ,8eca 18 CLC ,8ecb 65 9f ADC $9f ; add character width ,8ecd a8 TAY ,8ece c9 10 CMP #$10 ,8ed0 90 02 BCC $8ed4 ,8ed2 e6 f7 INC $f7 ; spans across three char boxes ,8ed4 c9 08 CMP #$08 ,8ed6 29 07 AND #$07 ,8ed8 49 07 EOR #$07 ,8eda 85 fd STA $fd ; new bit number ,8edc b0 0c BCS $8eea ,8ede aa TAX ; fits in single character box ,8edf bd 45 81 LDA $8145,X ,8ee2 05 a4 ORA $a4 ,8ee4 85 a4 STA $a4 ; combine left and right side masks ,8ee6 a9 ff LDA #$ff ; leave second byte untouched ,8ee8 d0 04 BNE $8eee ,8eea aa TAX ,8eeb bd 45 81 LDA $8145,X ,8eee 85 96 STA $96 ; right side mask ,8ef0 98 TYA ,8ef1 29 f8 AND #$f8 ,8ef3 18 CLC ,8ef4 65 fe ADC $fe ; calculate new drawing position ,8ef6 85 fe STA $fe ,8ef8 90 02 BCC $8efc ,8efa e6 ff INC $ff ,8efc a0 00 LDY #$00 ,8efe b1 a7 LDA ($a7),Y ; get character bit pattern ,8f00 f0 17 BEQ $8f19 ,8f02 24 a3 BIT $a3 ,8f04 10 05 BPL $8f0b ,8f06 85 9e STA $9e ; make bold ,8f08 4a LSR ,8f09 05 9e ORA $9e ,8f0b a6 a9 LDX $a9 ; rotation count ,8f0d f0 0a BEQ $8f19 ,8f0f 84 c3 STY $c3 ; clear byte used for rotation ,8f11 0a ASL ,8f12 26 c3 ROL $c3 ,8f14 ca DEX ,8f15 d0 fa BNE $8f11 ,8f17 f0 0d BEQ $8f26 ,8f19 85 c3 STA $c3 ; save pixels for rotation ,8f1b 98 TYA ,8f1c a6 aa LDX $aa ; rotation count ,8f1e f0 06 BEQ $8f26 ,8f20 46 c3 LSR $c3 ,8f22 6a ROR ,8f23 ca DEX ,8f24 d0 fa BNE $8f20 ,8f26 aa TAX ,8f27 b1 a5 LDA ($a5),Y ; get screen byte ,8f29 25 a4 AND $a4 ; mask ,8f2b 05 c3 ORA $c3 ; put character pixels ,8f2d 91 a5 STA ($a5),Y ; update screen byte ,8f2f a0 08 LDY #$08 ,8f31 a5 f7 LDA $f7 ,8f33 d0 0d BNE $8f42 ,8f35 b1 a5 LDA ($a5),Y ; get next screen byte on right ,8f37 25 96 AND $96 ; mask ,8f39 91 a5 STA ($a5),Y ,8f3b 8a TXA ,8f3c 11 a5 ORA ($a5),Y ; put character pixels ,8f3e d0 0b BNE $8f4b ; update screen byte ,8f40 f0 09 BEQ $8f4b ,8f42 8a TXA ,8f43 91 a5 STA ($a5),Y ; put character pixels straight to screen ,8f45 a0 10 LDY #$10 ,8f47 b1 a5 LDA ($a5),Y ; get next screen byte on right ,8f49 25 96 AND $96 ; mask ,8f4b 91 a5 STA ($a5),Y ; update screen byte ,8f4d 18 CLC ,8f4e a5 a7 LDA $a7 ; move character defition address to next scanline ,8f50 69 6f ADC #$6f ,8f52 85 a7 STA $a7 ,8f54 90 02 BCC $8f58 ,8f56 e6 a8 INC $a8 ,8f58 e6 a5 INC $a5 ; move screen pointer one line down ,8f5a d0 02 BNE $8f5e ,8f5c e6 a6 INC $a6 ,8f5e a5 a5 LDA $a5 ,8f60 29 07 AND #$07 ,8f62 d0 0d BNE $8f71 ,8f64 18 CLC ; char-box line crossing ,8f65 a5 a5 LDA $a5 ,8f67 69 38 ADC #$38 ,8f69 85 a5 STA $a5 ,8f6b a5 a6 LDA $a6 ,8f6d 69 01 ADC #$01 ,8f6f 85 a6 STA $a6 ,8f71 c6 c4 DEC $c4 ; decrement line counter ,8f73 d0 87 BNE $8efc ,8f75 60 RTS # call #1c - CONVERT PETSCII TO ASCII CODE >8f76 ; -- convert character code ] descr: ] Convert PETSCII codes to ASCII-like codes ] used for displaying text ] note: ] Convertion: $a0 -> $20 ] $c0-$df -> $60-$7f ] $e0-$ff -> $40-$5f ] $00-$1f,$7b-$7f,$80-$9f,$a1-$bf -> $00 ] input: ] x = PETSCII code ] output: ] x = converted code ,8f76 e0 a0 CPX #$a0 ,8f78 d0 02 BNE $8f7c ,8f7a a2 20 LDX #$20 ,8f7c e0 80 CPX #$80 ,8f7e 90 08 BCC $8f88 ,8f80 e0 c0 CPX #$c0 ,8f82 90 0c BCC $8f90 ,8f84 8a TXA ,8f85 49 a0 EOR #$a0 ,8f87 aa TAX ,8f88 e0 20 CPX #$20 ,8f8a 90 04 BCC $8f90 ,8f8c e0 7b CPX #$7b ,8f8e 90 02 BCC $8f92 ,8f90 a2 00 LDX #$00 ,8f92 60 RTS # call #1d - SELECT WINDOW >8f93 ; -- select window ] descr: ] Store selected window address at $94,$95 ] Cache selected window properties ] Update selected window procedure ] Clear keyboard buffer ] note: ] Selected window procedure is called continuously in idle loop ] input: ] x,y = window address ] output: ] $94,$95 = selected window address ] $c000,$c001 = window position ] $c002,$c003 = window size ] $c004 = window flags ] $c005 = title width ] $c006,$c007 = gadgets ] $0338,$0339 = window procedure ,8f93 86 94 STX $94 ; window address ,8f95 84 95 STY $95 ,8f97 a0 02 LDY #$02 ,8f99 b1 94 LDA ($94),Y ; position ,8f9b 8d 00 c0 STA $c000 ,8f9e c8 INY ,8f9f b1 94 LDA ($94),Y ,8fa1 8d 01 c0 STA $c001 ,8fa4 a0 04 LDY #$04 ,8fa6 b1 94 LDA ($94),Y ; width and height ,8fa8 8d 02 c0 STA $c002 ,8fab c8 INY ,8fac b1 94 LDA ($94),Y ,8fae 8d 03 c0 STA $c003 ,8fb1 a0 08 LDY #$08 ,8fb3 b1 94 LDA ($94),Y ; flags ,8fb5 8d 04 c0 STA $c004 ,8fb8 a0 09 LDY #$09 ,8fba b1 94 LDA ($94),Y ; title width ,8fbc 8d 05 c0 STA $c005 ,8fbf a0 00 LDY #$00 ,8fc1 b1 94 LDA ($94),Y ; list of gadgets ,8fc3 8d 06 c0 STA $c006 ,8fc6 c8 INY ,8fc7 b1 94 LDA ($94),Y ,8fc9 8d 07 c0 STA $c007 ,8fcc a0 0a LDY #$0a ,8fce b1 94 LDA ($94),Y ; window procedure ,8fd0 8d 38 03 STA $0338 ,8fd3 c8 INY ,8fd4 b1 94 LDA ($94),Y ,8fd6 8d 39 03 STA $0339 ,8fd9 a9 00 LDA #$00 ,8fdb 85 c6 STA $c6 ; clear keyboard buffer ,8fdd 60 RTS # call #1e - DRAW WINDOW BORDER >8fde ; -- draw window border ] descr: ] Draw window border, title bar and title bar buttons ] note: ] Resize button is drawn if window has RESIZE flag set, ] but it remains inactive as resizing is not implemented ] input: ] $94,$95 = window address ] $c000,$c001 = window position ] $c002,$c003 = window size ] $c004 = flags ] uses: ] $9e,$a3-$aa,$c3,$c4,$f7-$fc ] $c00c-$c00e ] calls: ] $815d = move drawing pointer ] $90a4 = save drawing address ] $8237 = draw background color box ] $90b4 = restore drawing address ] $8233 = draw foreground color box ] $91f2 = set drawing pointer relative to window ] $840a = draw text ] $90c4 = draw window drag bar ] $85bb = draw image ] output: ] $c008-$c00a = drawing start address ] $c00b = width of drag bar ,8fde ae 00 c0 LDX $c000 ; get window position ,8fe1 ac 01 c0 LDY $c001 ,8fe4 20 5d 81 JSR $815d ; move drawing pointer ,8fe7 20 a4 90 JSR $90a4 ; save drawing address ,8fea ae 02 c0 LDX $c002 ; get window size ,8fed ac 03 c0 LDY $c003 ,8ff0 20 37 82 JSR $8237 ; clear window box ,8ff3 20 b4 90 JSR $90b4 ; restore drawing address ,8ff6 ae 02 c0 LDX $c002 ,8ff9 ac 03 c0 LDY $c003 ,8ffc 20 0b 82 JSR $820b ; draw border ,8fff 20 b4 90 JSR $90b4 ; restore drawing address ,9002 ae 02 c0 LDX $c002 ; window width ,9005 a0 0b LDY #$0b ; height = 11 ,9007 20 33 82 JSR $8233 ; draw title bar ,900a a2 02 LDX #$02 ; no close box - title position: (2,2) ,900c a9 01 LDA #$01 ,900e 2d 04 c0 AND $c004 ; test CLOSE flag ,9011 f0 02 BEQ $9015 ,9013 a2 0f LDX #$0f ; close box on - title position: (15,2) ,9015 a0 02 LDY #$02 ,9017 20 f2 91 JSR $91f2 ; set drawing pointer relative to window ,901a a0 06 LDY #$06 ; get screen title address ,901c b1 94 LDA ($94),Y ,901e aa TAX ,901f c8 INY ,9020 b1 94 LDA ($94),Y ,9022 f0 06 BEQ $902a ,9024 a8 TAY ,9025 a9 01 LDA #$01 ; attributes: spacing=1, no bold, single width, single height ,9027 20 0a 84 JSR $840a ; draw window title ,902a a9 08 LDA #$08 ,902c 2d 04 c0 AND $c004 ; test MOVE flag ,902f f0 24 BEQ $9055 ,9031 ae 05 c0 LDX $c005 ; title width ,9034 a0 00 LDY #$00 ,9036 20 f2 91 JSR $91f2 ; set drawing pointer relative to window ,9039 18 CLC ,903a ad 02 c0 LDA $c002 ; window width - title width ,903d ed 05 c0 SBC $c005 ,9040 90 13 BCC $9055 ; title width > window width ,9042 aa TAX ,9043 a9 02 LDA #$02 ,9045 2d 04 c0 AND $c004 ; test TO BACK flag ,9048 f0 07 BEQ $9051 ,904a 8a TXA ,904b e9 0e SBC #$0e ; leave space for TO BACK icon ,904d 90 06 BCC $9055 ,904f b0 01 BCS $9052 ,9051 8a TXA ,9052 20 c4 90 JSR $90c4 ; draw drag bar ,9055 a9 01 LDA #$01 ,9057 2d 04 c0 AND $c004 ; test CLOSE flag ,905a f0 0e BEQ $906a ,905c a2 01 LDX #$01 ,905e a0 00 LDY #$00 ,9060 20 f2 91 JSR $91f2 ; set drawing position (1,0) ,9063 a2 00 LDX #$00 ,9065 a0 a0 LDY #$a0 ,9067 20 bb 85 JSR $85bb ; draw CLOSE button ,906a a9 02 LDA #$02 ,906c 2d 04 c0 AND $c004 ; test TO BACK flag ,906f f0 13 BEQ $9084 ,9071 18 CLC ,9072 ad 02 c0 LDA $c002 ; x = window width - 12 ,9075 e9 0c SBC #$0c ,9077 aa TAX ,9078 a0 00 LDY #$00 ,907a 20 f2 91 JSR $91f2 ; set drawing position ,907d a2 1c LDX #$1c ,907f a0 a0 LDY #$a0 ,9081 20 bb 85 JSR $85bb ; draw TO BACK button ,9084 a9 04 LDA #$04 ,9086 2d 04 c0 AND $c004 ; test RESIZE flag ,9089 f0 18 BEQ $90a3 ,908b 18 CLC ,908c ad 03 c0 LDA $c003 ; y = window height - 8 ,908f e9 08 SBC #$08 ,9091 a8 TAY ,9092 18 CLC ,9093 ad 02 c0 LDA $c002 ; x = window width - 8 ,9096 e9 08 SBC #$08 ,9098 aa TAX ,9099 20 f2 91 JSR $91f2 ; set drawing position ,909c a2 38 LDX #$38 ,909e a0 a0 LDY #$a0 ,90a0 20 bb 85 JSR $85bb ; draw RESIZE button ,90a3 60 RTS # call #1f - SAVE DRAWING POSITION ADDRESS >90a4 ; -- save drawing position address ] descr: ] Save current drawing position at addresses $c008-$c00a. ] note: ] Used in window drawing routine. ] input: ] $fd-$ff = current drawing address ] output: ] $c008-$c00a = window drawing address ,90a4 a5 fe LDA $fe ,90a6 a6 ff LDX $ff ,90a8 a4 fd LDY $fd ,90aa 8d 08 c0 STA $c008 ,90ad 8e 09 c0 STX $c009 ,90b0 8c 0a c0 STY $c00a ,90b3 60 RTS # call #20 - RESTORE DRAWING POSITION ADDRESS >90b4 ; -- restore drawing position address ] descr: ] Restore current drawing position from addresses $c008-$c00a. ] note: ] Used in window drawing routine. ] input: ] $c008-$c00a = window drawing address ] output: ] $fd-$ff = current drawing address ,90b4 ad 08 c0 LDA $c008 ,90b7 ae 09 c0 LDX $c009 ,90ba ac 0a c0 LDY $c00a ,90bd 85 fe STA $fe ,90bf 86 ff STX $ff ,90c1 84 fd STY $fd ,90c3 60 RTS >90c4 ; -- draw window drag bar ] descr: ] Draw window drag bar. ] note: ] Each 32-pixel wide segment is drawn as image. ] Last segment is drawn using separate procedure ] drawing partial images ] input: ] a = drag bar width ] $fa-$fc = current drawing position line and column ] $fd-$ff = current drawing position address ] uses: ] $9e,$a3-$aa,$c3,$c4,$f7-$f9 ] $c00b = drag bar width ] $c00c-$c00e = saved position ] calls: ] $85bb = draw image ] $815f = move graphics cursor ] $85c6 = draw partial image ,90c4 8d 0b c0 STA $c00b ; drag bar width # call #20 - DRAW WINDOW DRAG BAR >90c7 ; -- draw window drag bar ] descr: ] Draw window drag bar. ] note: ] Each 32-pixel wide segment is drawn as image. ] Last segment is drawn using separate procedure ] drawing partial images ] input: ] $c00b = drag bar width ] $fa-$fc = current drawing position line and column ] $fd-$ff = current drawing position address ] uses: ] $9e,$a3-$aa,$c3,$c4,$f7-$f9 ] $c00c-$c00e = saved position ] calls: ] $85bb = draw image ] $815f = move graphics cursor ] $85c6 = draw partial image ,90c7 a5 fa LDA $fa ,90c9 a6 fb LDX $fb ,90cb a4 fc LDY $fc ,90cd 8d 0c c0 STA $c00c ; save position ,90d0 8e 0d c0 STX $c00d ,90d3 8c 0e c0 STY $c00e ,90d6 18 CLC ,90d7 ad 0b c0 LDA $c00b ; width > 32 ? ,90da e9 1f SBC #$1f ,90dc 90 27 BCC $9105 ,90de 8d 0b c0 STA $c00b ; width = width - 32 ,90e1 a2 50 LDX #$50 ; drag bar image address ,90e3 a0 a0 LDY #$a0 ,90e5 20 bb 85 JSR $85bb ; put drag bar image ,90e8 38 SEC ; move 32 columns right ,90e9 ad 0d c0 LDA $c00d ,90ec 69 1f ADC #$1f ,90ee aa TAX ,90ef ad 0c c0 LDA $c00c ,90f2 90 02 BCC $90f6 ,90f4 a9 01 LDA #$01 ,90f6 ac 0e c0 LDY $c00e ,90f9 8d 0c c0 STA $c00c ; update position ,90fc 8e 0d c0 STX $c00d ,90ff 20 5f 81 JSR $815f ; move graphics cursor ,9102 18 CLC ,9103 90 d1 BCC $90d6 ; close loop ,9105 ad 0b c0 LDA $c00b ; width ,9108 85 f8 STA $f8 ; set image width ,910a a2 50 LDX #$50 ; drag bar image address ,910c a0 a0 LDY #$a0 ,910e 86 fa STX $fa ,9110 84 fb STY $fb ,9112 a0 01 LDY #$01 ,9114 4c c6 85 JMP $85c6 ; draw partial image # call #22 - SELECT GADGET >9117 ; -- select gadget ] descr: ] Store gadget address at $9b,$9c ] Cache selected gadget properties ] input: ] x,y = gadget address ] output: ] $9b,$9c = selected gadget address ] $c00f,$c010 = gadget position ] $c011,$c012 = gadget size ] $c013 = gadget flags ] $c014,$c015 = next gadget ,9117 86 9b STX $9b ; save address ,9119 84 9c STY $9c ,911b a0 02 LDY #$02 ,911d b1 9b LDA ($9b),Y ,911f 8d 0f c0 STA $c00f ; gadget position x ,9122 c8 INY ,9123 b1 9b LDA ($9b),Y ,9125 8d 10 c0 STA $c010 ; gadget position y ,9128 a0 04 LDY #$04 ,912a b1 9b LDA ($9b),Y ,912c 8d 11 c0 STA $c011 ; gadget width ,912f c8 INY ,9130 b1 9b LDA ($9b),Y ,9132 8d 12 c0 STA $c012 ; gadget height ,9135 a0 08 LDY #$08 ,9137 b1 9b LDA ($9b),Y ,9139 8d 13 c0 STA $c013 ; gadget flags ,913c a0 00 LDY #$00 ,913e b1 9b LDA ($9b),Y ,9140 8d 14 c0 STA $c014 ; next gadget ,9143 c8 INY ,9144 b1 9b LDA ($9b),Y ,9146 8d 15 c0 STA $c015 ,9149 60 RTS # call #23 - DRAW GADGET >914a ; -- draw gadget ] descr: ] Draw gadget ] note: ] Also used for drawing message box buttons ] input: ] x,y = gadget address ] calls: ] $9117 = select gadget ] $91f2 = set drawing position relative to window ] $8563 = draw rectangle with shadow ] $820b = draw rectangle ] $920e = draw gadget text ] $9248 = draw gadget image ] $83a5 = invert box ] output: ] $9b,$9c = selected gadget address ] $c000,$c001 = window position ] $c00f,$c010 = gadget position ] $c011,$c012 = gadget size ] $c013 = gadget flags ] $c014,$c015 = next gadget ,914a 20 17 91 JSR $9117 ; select gadget ,914d a9 04 LDA #$04 ,914f 2d 13 c0 AND $c013 ; test FRAME flag ,9152 f0 25 BEQ $9179 ,9154 ae 0f c0 LDX $c00f ; gadget position x ,9157 ca DEX ,9158 ca DEX ,9159 ac 10 c0 LDY $c010 ; gadget position y ,915c 88 DEY ,915d 88 DEY ,915e 20 f2 91 JSR $91f2 ; set drawing pointer relative to window ,9161 ad 11 c0 LDA $c011 ; width ,9164 18 CLC ,9165 69 04 ADC #$04 ,9167 aa TAX ,9168 ad 12 c0 LDA $c012 ; height ,916b 18 CLC ,916c 69 04 ADC #$04 ,916e a8 TAY ,916f a9 08 LDA #$08 ,9171 2d 13 c0 AND $c013 ; test SHADOW flag ,9174 f0 06 BEQ $917c ,9176 20 63 85 JSR $8563 ; draw 3d frame ,9179 18 CLC ,917a 90 03 BCC $917f ,917c 20 0b 82 JSR $820b ; draw simple frame ,917f a0 06 LDY #$06 ; get gadget text address ,9181 b1 9b LDA ($9b),Y ,9183 aa TAX ,9184 c8 INY ,9185 b1 9b LDA ($9b),Y ,9187 f0 04 BEQ $918d ,9189 a8 TAY ,918a 20 0e 92 JSR $920e ; draw gadget text ,918d ad 13 c0 LDA $c013 ,9190 29 80 AND #$80 ; test STRING flag ,9192 f0 0c BEQ $91a0 ,9194 a0 11 LDY #$11 ; get gadget string address ,9196 b1 9b LDA ($9b),Y ,9198 aa TAX ,9199 c8 INY ,919a b1 9b LDA ($9b),Y ,919c a8 TAY ,919d 20 0e 92 JSR $920e ; draw string ,91a0 a0 0d LDY #$0d ; get gadget image address ,91a2 b1 9b LDA ($9b),Y ,91a4 aa TAX ,91a5 c8 INY ,91a6 b1 9b LDA ($9b),Y ,91a8 f0 04 BEQ $91ae ,91aa a8 TAY ,91ab 20 48 92 JSR $9248 ; draw gadget image ,91ae a9 02 LDA #$02 ,91b0 2d 13 c0 AND $c013 ; test STATUS flag ,91b3 f0 20 BEQ $91d5 ,91b5 a9 20 LDA #$20 ,91b7 2d 13 c0 AND $c013 ; test TOGGLE flag ,91ba f0 19 BEQ $91d5 ,91bc a9 01 LDA #$01 ,91be 2d 13 c0 AND $c013 ; test INVERT flag ,91c1 f0 12 BEQ $91d5 ,91c3 ae 0f c0 LDX $c00f ; gadget position ,91c6 ac 10 c0 LDY $c010 ,91c9 20 f2 91 JSR $91f2 ; move drawing pointer relative to window ,91cc ae 11 c0 LDX $c011 ; gadget size ,91cf ac 12 c0 LDY $c012 ,91d2 20 a5 83 JSR $83a5 ; invert gadget box ,91d5 a0 0a LDY #$0a ,91d7 b1 9b LDA ($9b),Y ,91d9 f0 0a BEQ $91e5 ,91db 85 a5 STA $a5 ; gadget drawing procedure ,91dd 88 DEY ,91de b1 9b LDA ($9b),Y ,91e0 85 a4 STA $a4 ,91e2 4c 54 de JMP $de54 ; switch to ROM 2 and call gadget drawing procedure ,91e5 60 RTS # call #24 - SET DRAWING POSITION RELATIVE TO GADGET >91e6 ; -- set drawing position relative to gadget ] descr: ] Set drawing position relative to gadget ] input: ] x = column ] y = line ] $c000,$c001 = window position ] $c00f,$c010 = gadget position ] uses: ] $c016 ] calls: ] $815f = set drawing position ] output: ] $fb = column ] $fa = most siginificant bit of column ] $fc = line ] $fe,$ff = address of current drawing position ] $fd = bit number of current drawing position ,91e6 8a TXA ; position x ,91e7 18 CLC ,91e8 6d 0f c0 ADC $c00f ; add gadget position x ,91eb aa TAX ,91ec 98 TYA ; position y ,91ed 18 CLC ,91ee 6d 10 c0 ADC $c010 ; add gadget position y ,91f1 a8 TAY # call #25 - SET DRAWING POSITION RELATIVE TO WINDOW >91f2 ; -- set drawing position relative to window ] descr: ] Set drawing position relative to window ] input: ] x = column ] y = line ] $c000,$c001 = window position ] uses: ] $c016 ] calls: ] $815f = set drawing position ] output: ] $fb = column ] $fa = most siginificant bit of column ] $fc = line ] $fe,$ff = address of current drawing position ] $fd = bit number of current drawing position ,91f2 a9 00 LDA #$00 ,91f4 8d 16 c0 STA $c016 ; MSB of position x ,91f7 18 CLC ,91f8 8a TXA ,91f9 6d 00 c0 ADC $c000 ; add window position x ,91fc aa TAX ,91fd 90 03 BCC $9202 ,91ff ee 16 c0 INC $c016 ; set MSB ,9202 18 CLC ,9203 98 TYA ,9204 6d 01 c0 ADC $c001 ; add window position y ,9207 a8 TAY ,9208 ad 16 c0 LDA $c016 ; get MSB ,920b 4c 5f 81 JMP $815f ; set screen position # call #26 - DRAW GADGET TEXT >920e ; -- draw gadget text ] descr: ] Draw gadget text ] note: ] Gadget text structure: x, y, attr, string[], 0 ] input: ] x,y = text address ] $c000,$c001 = window position ] $c00f,$c010 = gadget position ] uses: ] $a9,$aa = text address ] calls: ] $91e6 = set drawing position relative to gadget ] $840a = draw text ] output: ] y = string length ,920e 86 a9 STX $a9 ; save text address ,9210 84 aa STY $aa ,9212 a0 00 LDY #$00 ,9214 b1 a9 LDA ($a9),Y ,9216 aa TAX ; text position x ,9217 c8 INY ,9218 b1 a9 LDA ($a9),Y ,921a a8 TAY ; text position y ,921b 20 e6 91 JSR $91e6 ; set position relative to gadget ,921e a0 02 LDY #$02 ,9220 b1 a9 LDA ($a9),Y ; text attributes ,9222 85 a8 STA $a8 ,9224 a4 aa LDY $aa ; skip text header ,9226 18 CLC ,9227 a9 03 LDA #$03 ,9229 65 a9 ADC $a9 ,922b 90 01 BCC $922e ,922d c8 INY ,922e aa TAX ,922f a5 a8 LDA $a8 ,9231 20 0a 84 JSR $840a ; put text ,9234 60 RTS # call #27 - DRAW IMAGE RELATIVE TO WINDOW >9235 ; -- draw image relative to window ] descr: ] Draw image relative to window coordinates ] note: ] Image layout structure: x, y, pointer to image ] input: ] x,y = image address ] $c000,$c001 = window position ] $c00f,$c010 = gadget position ] uses: ] $a9,$aa = image address ] calls: ] $91f2 = set drawing position relative to window ] $85bb = draw image ,9235 86 a9 STX $a9 ,9237 84 aa STY $aa ,9239 a0 00 LDY #$00 ,923b b1 a9 LDA ($a9),Y ,923d aa TAX ,923e c8 INY ,923f b1 a9 LDA ($a9),Y ,9241 a8 TAY ,9242 20 f2 91 JSR $91f2 ,9245 4c 58 92 JMP $9258 # call #4d - DRAW GADGET IMAGE >9248 ; -- draw gadget image ] descr: ] Draw image relative to gadget coordinates ] note: ] Image layout structure: x, y, pointer to image ] input: ] x,y = image address ] $c000,$c001 = window position ] $c00f,$c010 = gadget position ] uses: ] $a9,$aa = image address ] calls: ] $91e6 = set drawing position relative to gadget ] $85bb = draw image ,9248 86 a9 STX $a9 ; save image address ,924a 84 aa STY $aa ,924c a0 00 LDY #$00 ,924e b1 a9 LDA ($a9),Y ,9250 aa TAX ; image position x ,9251 c8 INY ,9252 b1 a9 LDA ($a9),Y ,9254 a8 TAY ; image position y ,9255 20 e6 91 JSR $91e6 ; set position relative to gadget ,9258 a0 02 LDY #$02 ; actual image address ,925a b1 a9 LDA ($a9),Y ,925c aa TAX ,925d c8 INY ,925e b1 a9 LDA ($a9),Y ,9260 a8 TAY ,9261 20 bb 85 JSR $85bb ; draw image ,9264 60 RTS # call #28 - SAVE WINDOW SNAPSHOT IF BACKUP FLAG IS SET >9265 ; -- save window snapshot if backup flag set ] descr: ] If window doesn't have BACKUP flag set, do nothing. ] Create new image from window area snapshot, ] store it in memory area pointed to by $c021,$c022 ] Save pointer to newly created snapshot in window structure ] Update snapshot free memory pointer ($c021,$c022). ] Set window RESTORE flag. ] note: ] Allocates memory even if RESTORE flag is already set. ] Make sure that RESTORE flag is not already set before calling this or ] you will suffer memory leaks. ] input: ] $94,$95 = window address ] $c000,$c001 = window position ] $c002,$c003 = window size ] $c021,$c022 = snapshot free memory pointer ] uses: ] $f8,$f9 = window size ] calls: ] $815d = set drawing position ] $869c = grab image from screen ] output: ] $c021,$c022 = new free memory pointer ,9265 a0 08 LDY #$08 ,9267 b1 94 LDA ($94),Y ; get window flags ,9269 29 20 AND #$20 ; test BACKUP flag ,926b d0 01 BNE $926e ,926d 60 RTS ,926e ae 00 c0 LDX $c000 ; window position ,9271 ac 01 c0 LDY $c001 ,9274 20 5d 81 JSR $815d ,9277 ae 02 c0 LDX $c002 ; window size ,927a ac 03 c0 LDY $c003 ,927d 86 f8 STX $f8 ,927f 84 f9 STY $f9 ,9281 a0 08 LDY #$08 ,9283 b1 94 LDA ($94),Y ,9285 09 10 ORA #$10 ,9287 91 94 STA ($94),Y ; set RESTORE flag ,9289 8d 04 c0 STA $c004 ,928c a0 0c LDY #$0c ,928e ad 21 c0 LDA $c021 ; get free memory pointer ,9291 91 94 STA ($94),Y ; save address in window ,9293 aa TAX ,9294 c8 INY ,9295 ad 22 c0 LDA $c022 ,9298 91 94 STA ($94),Y ,929a a8 TAY ,929b 20 9c 86 JSR $869c ; copy window to backup buffer ,929e 8e 21 c0 STX $c021 ; update free memory pointer ,92a1 8c 22 c0 STY $c022 ,92a4 60 RTS # call #29 - RESTORE WINDOW SNAPSHOT OR REDRAW WINDOW >92a5 ; -- restore window snapshot or redraw window ] descr: ] If window doesn't have RESTORE flag set, jump to normal redraw window ] procedure, otherwise restore window from snapshot ] input: ] $94,$95 = window address ] $c000,$c001 = window position ] $c002,$c003 = window size ] calls: ] $815d = set drawing position ] $85bb = draw image ] $92c3 = redraw window ,92a5 a0 08 LDY #$08 ,92a7 b1 94 LDA ($94),Y ,92a9 29 10 AND #$10 ; test RESTORE flag ,92ab f0 16 BEQ $92c3 ,92ad ae 00 c0 LDX $c000 ; window position ,92b0 ac 01 c0 LDY $c001 ,92b3 20 5d 81 JSR $815d ; set drawing position ,92b6 a0 0c LDY #$0c ; get restore buffer address ,92b8 b1 94 LDA ($94),Y ,92ba aa TAX ,92bb c8 INY ,92bc b1 94 LDA ($94),Y ,92be a8 TAY ,92bf 20 bb 85 JSR $85bb ; draw image ,92c2 60 RTS # call #44 - REDRAW WINDOW >92c3 ; -- redraw window ] descr: ] Redraw window. ] input: ] $94,$95 = window address ] $c000,$c001 = window position ] $c002,$c003 = window size ] calls: ] $8fde = draw window border ] $914a = draw gadget ,92c3 20 de 8f JSR $8fde ; draw window border ,92c6 ae 06 c0 LDX $c006 ; get first gadget ,92c9 ac 07 c0 LDY $c007 ,92cc f0 0b BEQ $92d9 ,92ce 20 4a 91 JSR $914a ; draw gadget ,92d1 ae 14 c0 LDX $c014 ; get next gadget ,92d4 ac 15 c0 LDY $c015 ,92d7 d0 f5 BNE $92ce ,92d9 60 RTS # call #2a - LOCATE WINDOW ON WINDOWS LIST >92da ; -- locate window on windows list ] descr: ] Return position of window on windows list ] (0 = topmost window) ] input: ] $94,95 = window address ] output: ] y = window offset on list ] $ff = not found ,92da ae 23 c0 LDX $c023 ; get windows list length ,92dd f0 16 BEQ $92f5 ,92df a0 fe LDY #$fe ,92e1 ca DEX ,92e2 30 11 BMI $92f5 ,92e4 c8 INY ,92e5 c8 INY ,92e6 a5 95 LDA $95 ; compare window address with next address in list ,92e8 d9 25 c0 CMP $c025,Y ,92eb d0 f4 BNE $92e1 ,92ed a5 94 LDA $94 ,92ef d9 24 c0 CMP $c024,Y ,92f2 d0 ed BNE $92e1 ,92f4 60 RTS ,92f5 a0 ff LDY #$ff ; not found ,92f7 60 RTS # call #2b - INSERT WINDOW INTO WINDOWS LIST >92f8 ; -- insert window into windows list ] descr: ] Insert window into windows list ] input: ] $94,95 = window address ,92f8 ad 23 c0 LDA $c023 ,92fb f0 0b BEQ $9308 ,92fd 0a ASL ,92fe a8 TAY ,92ff b9 23 c0 LDA $c023,Y ; shift windows list ,9302 99 25 c0 STA $c025,Y ,9305 88 DEY ,9306 d0 f7 BNE $92ff ,9308 a5 94 LDA $94 ; insert new window on the beginning ,930a a6 95 LDX $95 ,930c 8d 24 c0 STA $c024 ,930f 8e 25 c0 STX $c025 ,9312 ee 23 c0 INC $c023 ; increment windows count ,9315 60 RTS # call #2c - REMOVE WINDOW FROM WINDOWS LIST >9316 ; -- remove window from windows list ] descr: ] Remove window from windows list. ] note: ] Window must be on the list. ] input: ] $94,95 = window address ] uses: ] $f7 ] calls: ] $92da = locate window on windows list ] output: ] $0339 = window procedure is cleared when last window is closed ,9316 20 da 92 JSR $92da ; locate window ,9319 ad 23 c0 LDA $c023 ,931c 0a ASL ,931d 85 f7 STA $f7 ,931f c8 INY ,9320 c8 INY ,9321 c4 f7 CPY $f7 ,9323 f0 0b BEQ $9330 ,9325 b9 24 c0 LDA $c024,Y ; shift windows list ,9328 99 22 c0 STA $c022,Y ,932b c8 INY ,932c c4 f7 CPY $f7 ,932e 90 f5 BCC $9325 ,9330 ce 23 c0 DEC $c023 ; decrement windows count ,9333 d0 05 BNE $933a ,9335 a9 00 LDA #$00 ,9337 8d 39 03 STA $0339 ; remove window procedure ,933a 60 RTS # call #2d - MOVE WINDOW TO FRONT OF LIST >933b ; -- move window to front of list ] descr: ] Move window to front of windows list ] note: ] Window must be on the list. ] input: ] $94,95 = window address ] calls: ] $92da = locate window on windows list ,933b 20 da 92 JSR $92da ; locate window on list ,933e 98 TYA ,933f f0 17 BEQ $9358 ,9341 b9 24 c0 LDA $c024,Y ,9344 48 PHA ,9345 be 25 c0 LDX $c025,Y ,9348 b9 23 c0 LDA $c023,Y ; shift preceeding windows down ,934b 99 25 c0 STA $c025,Y ,934e 88 DEY ,934f d0 f7 BNE $9348 ,9351 68 PLA ,9352 8d 24 c0 STA $c024 ; place window on the beginning ,9355 8e 25 c0 STX $c025 ,9358 60 RTS # call #2e - MOVE WINDOW TO BACK OF LIST >9359 ; -- move window to back of list ] descr: ] Move window to back of windows list ] note: ] Window must be on the list. ] input: ] $94,95 = window address ] uses: ] $f7,$a9,$aa ] calls: ] $92da = locate window on windows list ,9359 20 da 92 JSR $92da ; locate window on list ,935c ad 23 c0 LDA $c023 ,935f 0a ASL ,9360 85 f7 STA $f7 ,9362 c6 f7 DEC $f7 ,9364 b9 24 c0 LDA $c024,Y ; shift following windows up ,9367 85 a9 STA $a9 ,9369 b9 25 c0 LDA $c025,Y ,936c 85 aa STA $aa ,936e b9 26 c0 LDA $c026,Y ,9371 99 24 c0 STA $c024,Y ,9374 c8 INY ,9375 c4 f7 CPY $f7 ,9377 30 f5 BMI $936e ,9379 a5 a9 LDA $a9 ,937b 99 23 c0 STA $c023,Y ; place window on back of list ,937e a5 aa LDA $aa ,9380 99 24 c0 STA $c024,Y ,9383 60 RTS # call #2f - CLEAR WINDOW AREA >9384 ; -- clear window area ] descr: ] Fill window area with background color. ] input: ] $c000,$c001 = window position ] $c002,$c003 = window size ] calls: ] $815d = set drawing position ] $8237 = background filled box ,9384 ae 00 c0 LDX $c000 ; get window position ,9387 ac 01 c0 LDY $c001 ,938a 20 5d 81 JSR $815d ; set graphics position ,938d ae 02 c0 LDX $c002 ; get window size ,9390 ac 03 c0 LDY $c003 ,9393 4c 37 82 JMP $8237 ; draw background box # call #30 - SHOW WINDOW >9396 ; -- show window ] descr: ] The show window procedure. ] If window is already topmost window, just select this window ] If window is already open, move it to front and redraw. ] Insert window into windows list ] If window has RESTORE flag set, restore window from snapshot, ] otherwise draw window border and gadgets ] If window has BACKUP flag set, but not RESTORE flag, ] save window snapshot. ] input: ] x,y = window address ] calls: ] $8f93 = select window ] $92da = locate window on list ] $98da = move window to front and redraw ] $92f8 = insert window into list ] $92a5 = restore window snapshot or redraw window ] $8fde = draw window border ] $914a = draw gadget ] $9265 = save window snapshot if BACKUP flag is set ,9396 ad 23 c0 LDA $c023 ; windows count ,9399 f0 0a BEQ $93a5 ,939b ec 24 c0 CPX $c024 ; check topmost window ,939e d0 05 BNE $93a5 ,93a0 cc 25 c0 CPY $c025 ; window is already active ,93a3 f0 34 BEQ $93d9 ,93a5 20 93 8f JSR $8f93 ; select window ,93a8 20 da 92 JSR $92da ; locate window on list ,93ab c0 ff CPY #$ff ,93ad f0 03 BEQ $93b2 ,93af 4c da 98 JMP $98da ; move window to front and redraw ,93b2 20 f8 92 JSR $92f8 ; insert window into list ,93b5 a0 08 LDY #$08 ,93b7 b1 94 LDA ($94),Y ,93b9 29 10 AND #$10 ; test RESTORE flag ,93bb f0 03 BEQ $93c0 ,93bd 4c a5 92 JMP $92a5 ; restore window shapshot ,93c0 20 de 8f JSR $8fde ; draw window border ,93c3 ae 06 c0 LDX $c006 ; get first gadget ,93c6 ac 07 c0 LDY $c007 ,93c9 f0 0b BEQ $93d6 ,93cb 20 4a 91 JSR $914a ; draw gadget ,93ce ae 14 c0 LDX $c014 ; get next gadget ,93d1 ac 15 c0 LDY $c015 ,93d4 d0 f5 BNE $93cb ,93d6 4c 65 92 JMP $9265 ; save window snapshot if enabled ,93d9 4c 93 8f JMP $8f93 ; select window # call #31 - GET NEXT WINDOW ON LIST >93dc ; -- get next window on list ] descr: ] Get address of next window on windows list ] input: ] x,y = window address ] calls: ] $92da = locate window on list ] output: ] x,y = next window address ,93dc 20 da 92 JSR $92da ; locate window on list ,93df c8 INY ,93e0 c8 INY ,93e1 98 TYA ,93e2 4a LSR ,93e3 cd 23 c0 CMP $c023 ,93e6 f0 0a BEQ $93f2 ; last window ,93e8 b9 24 c0 LDA $c024,Y ; get next window address ,93eb aa TAX ,93ec c8 INY ,93ed b9 24 c0 LDA $c024,Y ,93f0 a8 TAY ,93f1 60 RTS ,93f2 a9 00 LDA #$00 ,93f4 aa TAX ,93f5 a8 TAY ,93f6 60 RTS # call #32 - GET PREVIOUS WINDOW ON LIST >93f7 ; -- get previous window on list ] descr: ] Get address of previous window on windows list ] input: ] x,y = window address ] calls: ] $92da = locate window on list ] output: ] x,y = previous window address ,93f7 20 da 92 JSR $92da ; locate window on list ,93fa c0 00 CPY #$00 ,93fc f0 0c BEQ $940a ; first window ,93fe 88 DEY ,93ff 88 DEY ,9400 b9 24 c0 LDA $c024,Y ; get previous window address ,9403 aa TAX ,9404 c8 INY ,9405 b9 24 c0 LDA $c024,Y ,9408 a8 TAY ,9409 60 RTS ,940a a2 00 LDX #$00 ,940c 60 RTS # call #33 - HANDLE BUTTON CLICK >940d ; -- handle button click ] descr: ] Handle button click event. ] If non-topmost window is clicked outside title bar, bring it to front. ] Dispatch button click to menu bar, window title bars and window gadgets. ] calls: ] $ade8 = handle menu bar clicked ] $947f = window hit test ] $93dc = get next window ] $8f93 = select window ] $97ed = get pointer position within window ] $94d4 = handle window title bar clicked ] $98da = move window to front and redraw ] $94b1 = gadget hit test ] $9767 = handle gadget clicked ] input: ] $b4,$b5 = cursor position x ] $b6 = cursor position y ] $c023 = windows list ] uses: ] $a4,$a5 = topmost window address ,940d a5 b6 LDA $b6 ; cursor y ,940f c9 08 CMP #$08 ,9411 b0 07 BCS $941a ,9413 a5 b5 LDA $b5 ; cursor x - bit 8 ,9415 d0 03 BNE $941a ,9417 4c e8 ad JMP $ade8 ; handle menu click ,941a ad 23 c0 LDA $c023 ; get number of windows ,941d f0 57 BEQ $9476 ,941f a6 94 LDX $94 ; get topmost window ,9421 a4 95 LDY $95 ,9423 86 a4 STX $a4 ,9425 84 a5 STY $a5 ,9427 20 7f 94 JSR $947f ; test window hit ,942a b0 0f BCS $943b ,942c 20 dc 93 JSR $93dc ; get next window ,942f f0 3e BEQ $946f ,9431 20 93 8f JSR $8f93 ; select window ,9434 20 7f 94 JSR $947f ; test window hit ,9437 90 f3 BCC $942c ,9439 b0 0a BCS $9445 ; -- topmost window clicked ,943b 20 ed 97 JSR $97ed ; get pointer position within window ,943e c9 0c CMP #$0c ,9440 b0 13 BCS $9455 ,9442 4c d4 94 JMP $94d4 ; title bar clicked ; -- non-topmost window clicked ,9445 20 ed 97 JSR $97ed ; get pointer position within window ,9448 c9 0c CMP #$0c ,944a b0 03 BCS $944f ,944c 4c d4 94 JMP $94d4 ; title bar clicked ,944f 20 da 98 JSR $98da ; move window to front and redraw ,9452 20 ed 97 JSR $97ed ; get relative pointer position within window ,9455 ae 06 c0 LDX $c006 ; get first gadget ,9458 ac 07 c0 LDY $c007 ,945b f0 19 BEQ $9476 ,945d 20 17 91 JSR $9117 ; select gadget ,9460 20 b1 94 JSR $94b1 ; test gadget hit ,9463 b0 17 BCS $947c ,9465 ae 14 c0 LDX $c014 ; get next gadget ,9468 ac 15 c0 LDY $c015 ,946b d0 f0 BNE $945d ,946d f0 07 BEQ $9476 ,946f a6 a4 LDX $a4 ; topmost window address ,9471 a4 a5 LDY $a5 ,9473 20 93 8f JSR $8f93 ; re-select topmost window ,9476 ad c8 03 LDA $03c8 ; wait for button release ,9479 f0 fb BEQ $9476 ,947b 60 RTS ,947c 4c 67 97 JMP $9767 ; gadget clicked # call #34 - WINDOW HIT TEST >947f ; -- window hit test ] descr: ] Set carry if pointer is located inside window area ] input: ] $b4,$b5 = cursor position x ] $b6 = cursor position y ] $c000,$c001 = window position ] $c002,$c003 = window size ] output: ] c = 1: cursor inside window, 0: cursor outside window ,947f a5 b5 LDA $b5 ; cursor position x - bit 8 ,9481 d0 07 BNE $948a ,9483 a5 b4 LDA $b4 ; cursor position x ,9485 cd 00 c0 CMP $c000 ; window left edge ,9488 90 26 BCC $94b0 ; cursor outside window ,948a a5 b6 LDA $b6 ; cursor position y ,948c cd 01 c0 CMP $c001 ; window top edge ,948f 90 1f BCC $94b0 ; cursor outside window ,9491 a2 00 LDX #$00 ,9493 18 CLC ,9494 ad 00 c0 LDA $c000 ,9497 6d 02 c0 ADC $c002 ; window right edge ,949a 90 01 BCC $949d ,949c e8 INX ; window right edge MSB ,949d 38 SEC ,949e e5 b4 SBC $b4 ; cursor position x ,94a0 8a TXA ,94a1 e5 b5 SBC $b5 ,94a3 90 0b BCC $94b0 ; cursor outside window ,94a5 18 CLC ,94a6 ad 01 c0 LDA $c001 ,94a9 6d 03 c0 ADC $c003 ; window bottom edge ,94ac c5 b6 CMP $b6 ; cursor position y ,94ae 90 23 BCC $94d3 ,94b0 60 RTS # call #35 - GADGET HIT TEST >94b1 ; -- gadget hit test ] descr: ] Set carry if pointer is located inside gadget area ] input: ] $9f = relative cursor position x ] $96 = relative cursor position y ] $c00f,$c010 = gadget position x ] $c002,$c003 = gadget position y ] output: ] c = 1: cursor inside gadget, 0: cursor outside gadget ,94b1 a5 9f LDA $9f ; cursor position x ,94b3 cd 0f c0 CMP $c00f ; gadget left edge ,94b6 90 1b BCC $94d3 ,94b8 a5 96 LDA $96 ; cursor position y ,94ba cd 10 c0 CMP $c010 ; gadget top edge ,94bd 90 14 BCC $94d3 ,94bf 38 SEC ,94c0 ad 0f c0 LDA $c00f ,94c3 6d 11 c0 ADC $c011 ; gadget right edge ,94c6 c5 9f CMP $9f ,94c8 90 09 BCC $94d3 ,94ca 18 CLC ,94cb ad 10 c0 LDA $c010 ; gadget bottom edge ,94ce 6d 12 c0 ADC $c012 ,94d1 c5 96 CMP $96 ,94d3 60 RTS # call #36 - HANDLE WINDOW TITLE BAR CLICKED >94d4 ; -- handle window title bar clicked ] descr: ] Dispatch button click to title bar buttons ] Drag and reposition window if drag bar is clicked ] input: ] $c004 = window flags ] $c002 = window width ] uses: ] $c00f,$c010 = gadget (button) position ] $c011,$c012 = gadget size ] calls: ] $94b1 = gadget hit test ] $9981 = close window ] $9960 = move window to back ] $8bcd = draw window ] $98e1 = set window position ] $8f93 = select window ,94d4 ad 04 c0 LDA $c004 ,94d7 29 01 AND #$01 ; test CLOSE flag ,94d9 f0 1f BEQ $94fa ,94db a2 01 LDX #$01 ; close button position ,94dd a0 00 LDY #$00 ,94df 8e 0f c0 STX $c00f ,94e2 8c 10 c0 STY $c010 ,94e5 a2 09 LDX #$09 ; close button size ,94e7 a0 0b LDY #$0b ,94e9 8e 11 c0 STX $c011 ,94ec 8c 12 c0 STY $c012 ,94ef 20 b1 94 JSR $94b1 ; test close button hit ,94f2 90 06 BCC $94fa ,94f4 20 81 99 JSR $9981 ; close window ,94f7 18 CLC ,94f8 90 27 BCC $9521 ,94fa ad 04 c0 LDA $c004 ,94fd 29 02 AND #$02 ; test TO BACK flag ,94ff f0 26 BEQ $9527 ,9501 18 CLC ,9502 ad 02 c0 LDA $c002 ; window size ,9505 e9 0b SBC #$0b ,9507 8d 0f c0 STA $c00f ; to back button position ,950a a0 00 LDY #$00 ,950c 8c 10 c0 STY $c010 ,950f a2 0a LDX #$0a ; to back button size ,9511 a0 0b LDY #$0b ,9513 8e 11 c0 STX $c011 ,9516 8c 12 c0 STY $c012 ,9519 20 b1 94 JSR $94b1 ; test to back button hit ,951c 90 09 BCC $9527 ,951e 20 60 99 JSR $9960 ; move window to back ,9521 ad c8 03 LDA $03c8 ; wait for button release ,9524 f0 fb BEQ $9521 ,9526 60 RTS ,9527 ad 04 c0 LDA $c004 ,952a 29 08 AND #$08 ; test MOVE flag ,952c f0 23 BEQ $9551 ,952e a2 01 LDX #$01 ; drag bar position ,9530 a0 00 LDY #$00 ,9532 8e 0f c0 STX $c00f ,9535 8c 10 c0 STY $c010 ,9538 ad 02 c0 LDA $c002 ; window width ,953b 18 CLC ,953c e9 02 SBC #$02 ; drag bar width ,953e a0 0b LDY #$0b ; drag bar height ,9540 8d 11 c0 STA $c011 ,9543 8c 12 c0 STY $c012 ,9546 20 b1 94 JSR $94b1 ; test drag bar hit ,9549 90 06 BCC $9551 ,954b 20 cd 8b JSR $8bcd ; drag window ,954e 4c e1 98 JMP $98e1 ; set window position ,9551 4c 57 99 JMP $9957 ; select topmost window >9554 ; -- handle RADIO gadget clicked ] descr: ] Handle RADIO gadget clicked ] Select clicked gadget ] Deselect other gadgets on mutual exclusion list ] Call user defined gadget procedure ] input: ] $c013 = gadget flags ] $9b,$9c = gadget address ] uses: ] $9e,$9f = mutual exclusion list ] $f7 = mutual exclustion list index ] $c3,$c4 = saved gadget address ] calls: ] $97db = reverse gadget area ] $9117 = select gadget ,9554 ad 13 c0 LDA $c013 ,9557 29 02 AND #$02 ; test SELECTED flag ,9559 d0 0b BNE $9566 ,955b a0 08 LDY #$08 ,955d b1 9b LDA ($9b),Y ,955f 09 02 ORA #$02 ; set SELECTED flag ,9561 91 9b STA ($9b),Y ,9563 20 db 97 JSR $97db ; reverse gadget area ,9566 a6 9b LDX $9b ; save gadget address ,9568 a4 9c LDY $9c ,956a 86 c3 STX $c3 ,956c 84 c4 STY $c4 ,956e a0 10 LDY #$10 ,9570 b1 9b LDA ($9b),Y ; get mutual exclude gadgets list ,9572 85 9e STA $9e ,9574 c8 INY ,9575 b1 9b LDA ($9b),Y ,9577 85 9f STA $9f ,9579 a0 00 LDY #$00 ; clear list index ,957b 84 f7 STY $f7 ,957d a4 f7 LDY $f7 ; get next gadget address ,957f b1 9e LDA ($9e),Y ,9581 aa TAX ,9582 c8 INY ,9583 b1 9e LDA ($9e),Y ,9585 f0 24 BEQ $95ab ; end of list ,9587 c8 INY ,9588 84 f7 STY $f7 ,958a a8 TAY ; skip clicked gadget on list ,958b e4 c3 CPX $c3 ,958d d0 04 BNE $9593 ,958f c4 c4 CPY $c4 ,9591 f0 ea BEQ $957d ,9593 20 17 91 JSR $9117 ; select gadget ,9596 ad 13 c0 LDA $c013 ,9599 29 02 AND #$02 ; test SELECTED flag ,959b f0 e0 BEQ $957d ,959d a0 08 LDY #$08 ; clear SELECTED flag ,959f b1 9b LDA ($9b),Y ,95a1 49 02 EOR #$02 ,95a3 91 9b STA ($9b),Y ,95a5 20 db 97 JSR $97db ; reverse gadget area ,95a8 18 CLC ,95a9 90 d2 BCC $957d ; next gadget ,95ab a6 c3 LDX $c3 ,95ad a4 c4 LDY $c4 ,95af 20 17 91 JSR $9117 ; restore selected gadget ,95b2 ad c8 03 LDA $03c8 ; wait for button release ,95b5 f0 fb BEQ $95b2 ,95b7 4c ca 97 JMP $97ca ; call gadget click procedure # call #3a - CALCULATE STRING WIDTH >95ba ; -- calculate string width ] descr: ] Calculate width of given string in pixels ] input: ] x,y = text address ] $f7 = spacing, attributes (only bold) ] uses: ] $9e,$9f = text address ] $c3 = spacing ] $c4 = width ] output: ] x = width ,95ba a5 f7 LDA $f7 ; character spacing >95bc ; -- calculate string width ] descr: ] Calculate width of given string in pixels ] input: ] x,y = text address ] a = spacing, attributes (only bold) ] uses: ] $9e,$9f = text address ] $c3 = spacing ] $c4 = width ] output: ] x = width ,95bc 86 9e STX $9e ; save text address ,95be 84 9f STY $9f ,95c0 c9 00 CMP #$00 ,95c2 10 03 BPL $95c7 ,95c4 18 CLC ,95c5 69 01 ADC #$01 ,95c7 29 0f AND #$0f ,95c9 85 c3 STA $c3 ; spacing ,95cb a0 00 LDY #$00 ,95cd 84 c4 STY $c4 ,95cf b1 9e LDA ($9e),Y ; get next character ,95d1 f0 12 BEQ $95e5 ,95d3 10 02 BPL $95d7 ,95d5 49 a0 EOR #$a0 ; adjust code ,95d7 aa TAX ,95d8 38 SEC ,95d9 bd 79 a5 LDA $a579,X ; get character width ,95dc 65 c3 ADC $c3 ; add spacing ,95de 65 c4 ADC $c4 ; sum ,95e0 85 c4 STA $c4 ,95e2 c8 INY ,95e3 d0 ea BNE $95cf ,95e5 a6 c4 LDX $c4 ; result ,95e7 60 RTS >95e8 ; -- temporary save text address ] descr: ] Temporary save text address ] note: ] Used by string gadget edit procedure ] input: ] $fa,$fb = text address ] $fc = text length ] output: ] $a6,$a4 = text address ] $a5 = text length ,95e8 a5 fa LDA $fa ; text address ,95ea a6 fb LDX $fb ,95ec a4 fc LDY $fc ; text length ,95ee 85 a6 STA $a6 ,95f0 86 a4 STX $a4 ,95f2 84 a5 STY $a5 ,95f4 60 RTS >95f5 ; -- restore text address ] descr: ] Restore saved text address ] note: ] Used by string gadget edit procedure ] input: ] $a6,$a4 = text address ] $a5 = text length ] output: ] $fa,$fb = text address ] $fc = text length ,95f5 a5 a6 LDA $a6 ,95f7 a6 a4 LDX $a4 ,95f9 a4 a5 LDY $a5 ,95fb 85 fa STA $fa ; text address ,95fd 86 fb STX $fb ,95ff 84 fc STY $fc ; text length ,9601 60 RTS # call #55 - SHOW TEXT CURSOR AT CURRENT POSITION >9602 ; -- show text cursor at current position ] descr: ] Place text cursor at current drawing position ] Enable text cursor sprite ] note: ] Sprite #6 is used as text cursor ] input: ] $fa = position x - bit 8 ] $fb = position x ] $fc = position y ] calls: ] $9617 = place text cursor at current drawing position ,9602 20 17 96 JSR $9617 ; place text cursor at current drawing position ,9605 ad 15 d0 LDA $d015 ,9608 09 40 ORA #$40 ,960a 8d 15 d0 STA $d015 ; enable sprite #6 ,960d 60 RTS # call #56 - HIDE TEXT CURSOR ] descr: ] Disable text cursor sprite ] note: ] Sprite #6 is used as text cursor >960e ; -- hide text cursor ,960e ad 15 d0 LDA $d015 ,9611 29 bf AND #$bf ,9613 8d 15 d0 STA $d015 ; disable sprite #6 ,9616 60 RTS >9617 ; -- place text cursor at current drawing position ] descr: ] Place text cursor at current drawing position ] note: ] Sprite #6 is used as text cursor ] input: ] $fa = cursor position x - bit 8 ] $fb = cursor position x ] $fc = cursor position y ,9617 18 CLC ,9618 a6 fa LDX $fa ; cursor position x - bit 8 ,961a a5 fb LDA $fb ; cursor position x ,961c 69 17 ADC #$17 ; add VIC border size ,961e 90 01 BCC $9621 ,9620 e8 INX ,9621 8d 0c d0 STA $d00c ; set sprite #6 position x ,9624 ad 10 d0 LDA $d010 ,9627 e0 00 CPX #$00 ,9629 f0 04 BEQ $962f ,962b 09 40 ORA #$40 ,962d d0 02 BNE $9631 ,962f 29 bf AND #$bf ,9631 8d 10 d0 STA $d010 ; set sprite #6 position x - bit 8 ,9634 18 CLC ,9635 a5 fc LDA $fc ; cursor position y ,9637 69 31 ADC #$31 ; add VIC border size ,9639 8d 0d d0 STA $d00d ; set sprite #6 position y ,963c 60 RTS >963d ; -- move text cursor one character right ] descr: ] Move cursor one character right ] input: ] $9f = character width ,963d 18 CLC ,963e a2 00 LDX #$00 ,9640 ad 0c d0 LDA $d00c ; sprite #6 position x ,9643 65 9f ADC $9f ; character width ,9645 90 02 BCC $9649 ,9647 a2 40 LDX #$40 ,9649 8d 0c d0 STA $d00c ,964c 8a TXA ,964d 0d 10 d0 ORA $d010 ; position x - bit 8 ,9650 8d 10 d0 STA $d010 ,9653 60 RTS >9654 ; -- edit string gadget ] descr: ] Edit string gadget ] input: ] $c002,$c003 = text position ] $c004 = text attributes ] $c005 = max text length ] $c006,$c007 = text address ] uses: ] $fa,$fb = text address ] $fc = text length ] $c6 ] calls: ] $96fc = place text cursor at end of text ] $b370 = backup zero page registers ] $de65 = update clock ] $b391 = restore zero page registers ] $ffe4 = read key ] $8f76 = convert char code ] $8e74 = display single character ] $963d = move cursor one character right ] $960e = hide text cursor ] $95e8 = temporary save text address ] $95f5 = restore text address ] $90a4 = save drawing position address ] $90b4 = restore drawing position address ,9654 ad 04 c0 LDA $c004 ; string gadget attributes ,9657 85 a3 STA $a3 ,9659 20 fc 96 JSR $96fc ; place text cursor at end of text ,965c 20 02 96 JSR $9602 ; show text cursor ,965f ae 06 c0 LDX $c006 ; text address ,9662 ac 07 c0 LDY $c007 ,9665 86 fa STX $fa ,9667 84 fb STY $fb ,9669 a0 00 LDY #$00 ; get string length ,966b 84 c6 STY $c6 ,966d b1 fa LDA ($fa),Y ,966f f0 03 BEQ $9674 ,9671 c8 INY ,9672 d0 f9 BNE $966d ,9674 84 fc STY $fc ; save string length ; -- edit loop ,9676 20 70 b3 JSR $b370 ; backup zero page ,9679 20 65 de JSR $de65 ; update clock ,967c 20 91 b3 JSR $b391 ; restore zero page ,967f ad c8 03 LDA $03c8 ,9682 d0 04 BNE $9688 ; button clicked ,9684 a9 0d LDA #$0d ,9686 d0 03 BNE $968b ; simutate RETURN, end text edition ,9688 20 e4 ff JSR $ffe4 ; read key ,968b a4 fc LDY $fc ; string index ,968d aa TAX ,968e c9 8d CMP #$8d ; SHIFT+RETURN ,9690 f0 2c BEQ $96be ,9692 c9 0d CMP #$0d ; RETURN ,9694 f0 28 BEQ $96be ,9696 c9 14 CMP #$14 ; DELETE ,9698 f0 40 BEQ $96da ,969a c9 94 CMP #$94 ; SHIFT+DELETE ,969c f0 3c BEQ $96da ,969e c9 a0 CMP #$a0 ; SHIFT+SPACE ,96a0 d0 02 BNE $96a4 ,96a2 a9 20 LDA #$20 ; convert SHIFT+SPACE to SPACE ,96a4 20 76 8f JSR $8f76 ; convert code to display code ,96a7 e0 41 CPX #$41 ; 'a' ,96a9 90 08 BCC $96b3 ,96ab e0 5b CPX #$5b ; 'z' ,96ad b0 04 BCS $96b3 ,96af 8a TXA ; convert letters to upper case ,96b0 09 20 ORA #$20 ,96b2 aa TAX ,96b3 e0 00 CPX #$00 ; no key or ignored key ,96b5 f0 bf BEQ $9676 ; get next ,96b7 cc 05 c0 CPY $c005 ; check string length ,96ba d0 06 BNE $96c2 ,96bc a2 00 LDX #$00 ; max string length reached ,96be a9 00 LDA #$00 ; add NUL ,96c0 f0 02 BEQ $96c4 ,96c2 e6 fc INC $fc ; increment string index ,96c4 91 fa STA ($fa),Y ; put character at current position ,96c6 e0 8d CPX #$8d ; SHIFT+RETURN (NUL already added) ,96c8 f0 0d BEQ $96d7 ; end string edition ,96ca e0 0d CPX #$0d ; RETURN ,96cc f0 09 BEQ $96d7 ; end string edition ,96ce 20 74 8e JSR $8e74 ; display character ,96d1 20 3d 96 JSR $963d ; move text cursor ,96d4 4c 76 96 JMP $9676 ; get next character ,96d7 4c 0e 96 JMP $960e ; hide text cursor ; -- delete character ,96da c0 00 CPY #$00 ,96dc f0 98 BEQ $9676 ; string empty ,96de 88 DEY ; decrement string index ,96df a9 00 LDA #$00 ,96e1 91 fa STA ($fa),Y ; remove character ,96e3 84 fc STY $fc ; save string length ,96e5 20 e8 95 JSR $95e8 ; save text address and length ,96e8 20 fc 96 JSR $96fc ; place text cursor at end of text ,96eb 20 f5 95 JSR $95f5 ; restore text address and length ,96ee 20 a4 90 JSR $90a4 ; save drawing position address ,96f1 a2 7b LDX #$7b ; character 7b - erase ,96f3 20 74 8e JSR $8e74 ; display character ,96f6 20 b4 90 JSR $90b4 ; restore drawing position address ,96f9 4c 76 96 JMP $9676 ; get next character >96fc ; -- place text cursor at end of text ] descr: ] Place text cursor at end of text ] input: ] $c002,$c003 = text position ] $c006,$c007 = text address ] calls: ] $91e6 = set drawing position relative to gadget ] $95bc = calculate text width ] $8165 = set current drawing position address ] $9617 = move text cursor to current position ] output: ] $fd-$ff = new drawing position ,96fc ae 02 c0 LDX $c002 ; string position ,96ff ac 03 c0 LDY $c003 ,9702 20 e6 91 JSR $91e6 ; set drawing position relative to gadget ,9705 ae 06 c0 LDX $c006 ; text address ,9708 ac 07 c0 LDY $c007 ,970b a9 01 LDA #$01 ; spacing ,970d 20 bc 95 JSR $95bc ; calculate string width ,9710 18 CLC ,9711 8a TXA ,9712 65 fb ADC $fb ,9714 85 fb STA $fb ,9716 90 02 BCC $971a ,9718 e6 fa INC $fa ; add string width to position x ,971a 20 65 81 JSR $8165 ; set drawing position ,971d 20 17 96 JSR $9617 ; move text cursor to current position ,9720 60 RTS >9721 ; -- handle STRING gadget clicked ] descr: ] Handle STRING gadget clicked ] Wait for button release ] Get gadget string parameters ] Edit string ] Call user defined gadget procedure ] input: ] $9b,$9c = gadget address ] uses: ] $c005 = max text legnth ] $9e,$9f = text address ] $c002,$c003 = text position ] $c004 = text attributes ] $c006,$c007 = text address ] calls: ] $9654 = edit string gadget ] $8f93 = select window ,9721 a0 10 LDY #$10 ,9723 b1 9b LDA ($9b),Y ,9725 8d 05 c0 STA $c005 ; max string length ,9728 c8 INY ,9729 b1 9b LDA ($9b),Y ,972b 85 9e STA $9e ; string address ,972d c8 INY ,972e b1 9b LDA ($9b),Y ,9730 85 9f STA $9f ,9732 a0 00 LDY #$00 ,9734 b1 9e LDA ($9e),Y ,9736 8d 02 c0 STA $c002 ; string position x ,9739 c8 INY ,973a b1 9e LDA ($9e),Y ,973c 8d 03 c0 STA $c003 ; string position y ,973f c8 INY ,9740 b1 9e LDA ($9e),Y ,9742 8d 04 c0 STA $c004 ; string attributes ,9745 c8 INY ,9746 18 CLC ,9747 98 TYA ,9748 a6 9f LDX $9f ,974a 65 9e ADC $9e ,974c 8d 06 c0 STA $c006 ; text address ,974f 90 01 BCC $9752 ,9751 e8 INX ,9752 8e 07 c0 STX $c007 ,9755 ad c8 03 LDA $03c8 ; wait for button release ,9758 f0 fb BEQ $9755 ,975a 20 54 96 JSR $9654 ; edit string ,975d a6 94 LDX $94 ,975f a4 95 LDY $95 ,9761 20 93 8f JSR $8f93 ; re-select window ,9764 4c ca 97 JMP $97ca ; call gadget click procedure # call #37 - HANDLE GADGET CLICKED ] descr: ] Handle gadget clicked ] RADIO and STRING gadgets are handled by specific functions ] Invert gadget area if INVERT flag is set ] Toggle SELECTED flag if TOGGLE flag is set ] Wait for button release if RELEASE flag is set ] Un-invert gadget if INVERT is set and TOGGLE is not set ] Call user defined gadget procedure ] input: ] $c013 = gadget flags ] $b4,$b6 = cursor position ] $c000,$c001 = window position ] uses: ] $a4,$a5 = user defined gadget procedure ] calls: ] $9554 = handle RADIO gadget ] $9721 = handle STRING gadget ] $97db = invert gadget area ] $94b1 = gadget hit test >9767 ; -- handle gadget clicked ,9767 ad 13 c0 LDA $c013 ,976a 29 40 AND #$40 ; test RADIO flag ,976c f0 03 BEQ $9771 ,976e 4c 54 95 JMP $9554 ; handle RADIO gadget ,9771 ad 13 c0 LDA $c013 ,9774 29 80 AND #$80 ; test STRING flag ,9776 f0 03 BEQ $977b ,9778 4c 21 97 JMP $9721 ; handle STRING gadget ,977b ad 13 c0 LDA $c013 ,977e 29 01 AND #$01 ; test INVERT flag ,9780 f0 03 BEQ $9785 ; -- handle INVERT flag ,9782 20 db 97 JSR $97db ; invert gadget area ,9785 ad 13 c0 LDA $c013 ,9788 29 20 AND #$20 ; test TOGGLE flag ,978a f0 0c BEQ $9798 ; -- handle TOGGLE flag ,978c a0 08 LDY #$08 ,978e ad 13 c0 LDA $c013 ; toggle SELECTED flag ,9791 49 02 EOR #$02 ,9793 8d 13 c0 STA $c013 ,9796 91 9b STA ($9b),Y ,9798 ad 13 c0 LDA $c013 ,979b 29 10 AND #$10 ; test RELEASE flag ,979d f0 2b BEQ $97ca ; -- handle RELEASE flag ,979f ad c8 03 LDA $03c8 ; wait for button release ,97a2 f0 fb BEQ $979f ,97a4 38 SEC ,97a5 a5 b4 LDA $b4 ; cursor position x ,97a7 ed 00 c0 SBC $c000 ; window position x ,97aa 85 9f STA $9f ; save relative position ,97ac 38 SEC ,97ad a5 b6 LDA $b6 ; cursor position y ,97af ed 01 c0 SBC $c001 ; window position y ,97b2 85 96 STA $96 ; save relative position ,97b4 a9 20 LDA #$20 ,97b6 2d 13 c0 AND $c013 ; test TOGGLE flag ,97b9 d0 0f BNE $97ca ,97bb a9 01 LDA #$01 ; TOGGLE flag not set ,97bd 2d 13 c0 AND $c013 ; test INVERT flag ,97c0 f0 03 BEQ $97c5 ,97c2 20 db 97 JSR $97db ; invert gadget area ,97c5 20 b1 94 JSR $94b1 ; test if pointer still within gadget area ,97c8 90 10 BCC $97da >97ca ; -- call gadget click procedure ,97ca a0 0b LDY #$0b ,97cc b1 9b LDA ($9b),Y ; gadget click procedure address ,97ce 85 a4 STA $a4 ,97d0 c8 INY ,97d1 b1 9b LDA ($9b),Y ,97d3 85 a5 STA $a5 ,97d5 f0 03 BEQ $97da ,97d7 4c 54 de JMP $de54 ; call gadget click procedure ,97da 60 RTS # call #38 - INVERT GADGET AREA >97db ; -- invert gadget area ] descr: ] Invert gadget area ] input: ] $c000,$c001 = window position ] $c00f,$c010 = gadget position ] $c011,$c012 = gadget size ] calls: ] $83a5 = Invert box ,97db ae 0f c0 LDX $c00f ; gadget position ,97de ac 10 c0 LDY $c010 # call #39 - INVERT GADGET AREA >97e1 ; -- invert gadget area ] descr: ] Invert gadget area ] input: ] $c000,$c001 = window position ] x,y = gadget position ] $c011,$c012 = gadget size ] calls: ] $83a5 = Invert box ,97e1 20 f2 91 JSR $91f2 ; set drawing position relative to window ,97e4 ae 11 c0 LDX $c011 ; gadget size ,97e7 ac 12 c0 LDY $c012 ,97ea 4c a5 83 JMP $83a5 ; reverse gadget area >97ed ; -- get relative pointer position within window ] descr: ] Get relative pointer position within window ] input: ] $b4 = cursor position x ] $b6 = cursor position y ] $c000 = window position x ] $c001 = window position y ] output: ] $9f = relative position x ] $96 = relative position y ] a = relative position y ,97ed 38 SEC ,97ee a5 b4 LDA $b4 ; cursor position x ,97f0 ed 00 c0 SBC $c000 ; window position x ,97f3 85 9f STA $9f ; store relative position ,97f5 38 SEC ,97f6 a5 b6 LDA $b6 ; cursor position y ,97f8 ed 01 c0 SBC $c001 ; windows position y ,97fb 85 96 STA $96 ; store relative position ,97fd 60 RTS # call #3b - UPDATE GADGET IN WINDOW SNAPSHOT IMAGE >97fe ; -- update gadget in window snapshot image ] descr: ] Update gadget in window snapshot image ] input: ] $c00f,$c010 = gadget position ] $c011,$c012 = gadget size ] uses: ] $a3,$a4,$a5,$a6,$a7,$a8 ] $f7,$f8,$f9 ] $fd,$fe,$ff = drawing position address ] $a9,$aa = snapshot address ] calls: ] $91f2 = set drawing position relative to window ] $8d69 = byte multiply ,97fe ae 0f c0 LDX $c00f ; gadget position x ,9801 ac 10 c0 LDY $c010 ; gadget position y ,9804 20 f2 91 JSR $91f2 ; set drawing position relative to window ,9807 18 CLC ,9808 a5 fd LDA $fd ; drawing position bit number ,980a 49 07 EOR #$07 ; counting from left ,980c 6d 11 c0 ADC $c011 ; add gadget width ,980f ac 12 c0 LDY $c012 ; gadget height ,9812 4a LSR ,9813 4a LSR ,9814 4a LSR ,9815 85 f8 STA $f8 ; gadget width in char-box wide units ,9817 84 f9 STY $f9 ; gadget height ,9819 a0 0c LDY #$0c ,981b b1 94 LDA ($94),Y ; window snapshot address ,981d 85 a9 STA $a9 ,981f c8 INY ,9820 b1 94 LDA ($94),Y ,9822 85 aa STA $aa ,9824 a0 02 LDY #$02 ,9826 18 CLC ,9827 b1 a9 LDA ($a9),Y ; image starting bit number (shift count) ,9829 49 07 EOR #$07 ,982b 6d 0f c0 ADC $c00f ; gadget position x ,982e 4a LSR ,982f 4a LSR ,9830 4a LSR ,9831 85 f7 STA $f7 ; image horizontal gadget offset in bytes ,9833 b1 a9 LDA ($a9),Y ; image starting bit number ,9835 49 07 EOR #$07 ,9837 18 CLC ,9838 6d 0f c0 ADC $c00f ; gadget position x ,983b 29 07 AND #$07 ,983d 49 07 EOR #$07 ; backup image gadget starting bit number ,983f 85 a3 STA $a3 ,9841 38 SEC ,9842 a5 fd LDA $fd ; source (screen) bit number ,9844 e5 a3 SBC $a3 ; destination (image) bit number ,9846 29 07 AND #$07 ,9848 85 fd STA $fd ; bit number difference ,984a 90 0d BCC $9859 ,984c e6 f8 INC $f8 ; increment byte count ,984e 38 SEC ; move screen address one char left ,984f a5 fe LDA $fe ,9851 e9 08 SBC #$08 ,9853 85 fe STA $fe ,9855 b0 02 BCS $9859 ,9857 c6 ff DEC $ff ,9859 c8 INY ,985a b1 a9 LDA ($a9),Y ; image width in bytes ,985c 85 a8 STA $a8 ,985e 18 CLC ,985f a5 a9 LDA $a9 ; move pointer to beginning of image bits ,9861 69 04 ADC #$04 ,9863 85 a9 STA $a9 ,9865 90 02 BCC $9869 ,9867 e6 aa INC $aa ,9869 a6 a8 LDX $a8 ; image width in bytes ,986b ac 10 c0 LDY $c010 ; gadget position y ,986e 20 69 8d JSR $8d69 ; multiply ,9871 18 CLC ,9872 a5 a9 LDA $a9 ; move image address to the first gadget line ,9874 65 a3 ADC $a3 ,9876 85 a9 STA $a9 ,9878 a5 aa LDA $aa ,987a 65 a4 ADC $a4 ,987c 85 aa STA $aa ; -- scanline loop ,987e a5 f8 LDA $f8 ; byte count ,9880 85 a5 STA $a5 ,9882 a5 f7 LDA $f7 ; offset to gadget left edge ,9884 85 a7 STA $a7 ,9886 a0 00 LDY #$00 ,9888 b1 fe LDA ($fe),Y ; get first screen byte ,988a 85 a3 STA $a3 ,988c 98 TYA ; -- byte loop ,988d 18 CLC ,988e 69 08 ADC #$08 ,9890 a8 TAY ,9891 b1 fe LDA ($fe),Y ; get right screen byte ,9893 84 a6 STY $a6 ; screen offset ,9895 85 a4 STA $a4 ,9897 a6 fd LDX $fd ; shift count ,9899 f0 06 BEQ $98a1 ,989b 46 a3 LSR $a3 ; rotate bytes right ,989d 6a ROR ,989e ca DEX ,989f d0 fa BNE $989b ,98a1 a4 a7 LDY $a7 ; image offset ,98a3 91 a9 STA ($a9),Y ; store byte in image ,98a5 e6 a7 INC $a7 ; increment image offset ,98a7 a5 a4 LDA $a4 ; reuse right screen byte as left byte ,98a9 85 a3 STA $a3 ,98ab a5 a6 LDA $a6 ; screen offset ,98ad c6 a5 DEC $a5 ; decrement byte count ,98af 10 dc BPL $988d ; get next screen byte ,98b1 18 CLC ,98b2 a5 a9 LDA $a9 ; image address ,98b4 65 a8 ADC $a8 ; add scanline width ,98b6 85 a9 STA $a9 ,98b8 90 02 BCC $98bc ,98ba e6 aa INC $aa ,98bc e6 fe INC $fe ; move screen address down one line ,98be d0 02 BNE $98c2 ,98c0 e6 ff INC $ff ,98c2 a5 fe LDA $fe ,98c4 29 07 AND #$07 ,98c6 d0 0d BNE $98d5 ,98c8 18 CLC ; char-box line crossing ,98c9 a5 fe LDA $fe ,98cb 69 38 ADC #$38 ,98cd 85 fe STA $fe ,98cf a5 ff LDA $ff ,98d1 69 01 ADC #$01 ,98d3 85 ff STA $ff ,98d5 c6 f9 DEC $f9 ; decrement line count ,98d7 10 a5 BPL $987e ; close scanline loop ,98d9 60 RTS # call #3e - MOVE WINDOW TO FRONT >98da ; -- move window to front ] descr: ] Move window to front and redraw ] calls: ] $933b = move window to front of windows list ] $92a5 = redraw window ,98da 20 3b 93 JSR $933b ; move window to front of list ,98dd 20 a5 92 JSR $92a5 ; redraw window ,98e0 60 RTS # call #3f - SET WINDOW POSITION >98e1 ; -- set window position ] descr: ] Set window position ] input: ] x,y = new window position ] $94,$95 = window address ] $c000,$c001 = current window position ] $c002,$c003 = window size ] calls: ] $8e2e = switch output screen buffer ] $9384 = clear window area ] $92da = locate window on windows list ] $92a5 = redraw window ] $9994 = redraw all widnows [ $8e42 = switch visible screen buffer ] $815d = set drawing position ] $8237 = clear box ] $8f93 = select window ,98e1 ec 00 c0 CPX $c000 ; compare with current window postion x ,98e4 d0 05 BNE $98eb ,98e6 cc 01 c0 CPY $c001 ,98e9 f0 6c BEQ $9957 ; window didn't move - select window and return ,98eb 98 TYA ,98ec a0 03 LDY #$03 ,98ee 91 94 STA ($94),Y ; update window position y ,98f0 88 DEY ,98f1 8a TXA ,98f2 91 94 STA ($94),Y ; update window position x ,98f4 20 2e 8e JSR $8e2e ; switch output to back buffer ,98f7 20 84 93 JSR $9384 ; clear window area ,98fa 20 2e 8e JSR $8e2e ; switch output to visible buffer ,98fd 20 da 92 JSR $92da ; locate window on windows list ,9900 c0 00 CPY #$00 ; top window? ,9902 d0 08 BNE $990c ,9904 20 84 93 JSR $9384 ; clear window area ,9907 a9 00 LDA #$00 ,9909 8d 02 c0 STA $c002 ,990c ad 02 c0 LDA $c002 ; window size x ,990f 48 PHA ,9910 ad 03 c0 LDA $c003 ; window size y ,9913 48 PHA ,9914 ad 00 c0 LDA $c000 ; previous window position x ,9917 48 PHA ,9918 ad 01 c0 LDA $c001 ; previous window position y ,991b 48 PHA ,991c ad 02 c0 LDA $c002 ,991f d0 17 BNE $9938 ,9921 a0 02 LDY #$02 ; top window ,9923 b1 94 LDA ($94),Y ; new position x ,9925 8d 00 c0 STA $c000 ,9928 c8 INY ,9929 b1 94 LDA ($94),Y ; new position y ,992b 8d 01 c0 STA $c001 ,992e a0 04 LDY #$04 ,9930 b1 94 LDA ($94),Y ,9932 8d 02 c0 STA $c002 ; restore window size x ,9935 20 a5 92 JSR $92a5 ; redraw top window ,9938 20 2e 8e JSR $8e2e ; switch output to back buffer ,993b 20 94 99 JSR $9994 ; redraw all windows ,993e 20 42 8e JSR $8e42 ; switch visible buffer ,9941 20 2e 8e JSR $8e2e ; switch output to back buffer ,9944 68 PLA ,9945 a8 TAY ; previous window position y ,9946 68 PLA ,9947 aa TAX ; previous window position x ,9948 20 5d 81 JSR $815d ; set drawing position ,994b 68 PLA ; window size y ,994c a8 TAY ,994d 68 PLA ; window size x ,994e aa TAX ,994f f0 03 BEQ $9954 ; top window ,9951 20 37 82 JSR $8237 ; erase previous window rectangle from back buffer ,9954 4c 2e 8e JMP $8e2e ; switch output to visible buffer ,9957 ae 24 c0 LDX $c024 ; top window ,995a ac 25 c0 LDY $c025 ,995d 4c 93 8f JMP $8f93 ; select top window # call #40 - MOVE WINDOW TO BACK >9960 ; -- move window to back ] descr: ] Move window to back and redraw all windows ] input: ] $94,$95 = window address ] calls: ] $9359 = move window to back of list ] $8e2e = switch output screen buffer ] $9994 = redraw windows ] $8e42 = switch visible screen buffer ,9960 ad 23 c0 LDA $c023 ; windows count ,9963 0a ASL ,9964 a8 TAY ,9965 b9 22 c0 LDA $c022,Y ; get last window ,9968 c5 94 CMP $94 ,996a d0 08 BNE $9974 ,996c c8 INY ,996d b9 22 c0 LDA $c022,Y ,9970 c5 95 CMP $95 ,9972 f0 e3 BEQ $9957 ; selected window is already last ,9974 20 59 93 JSR $9359 ; move window to back of list ,9977 20 2e 8e JSR $8e2e ; switch output to back buffer ,997a 20 94 99 JSR $9994 ; redraw windows ,997d 20 42 8e JSR $8e42 ; switch visible screen buffer ,9980 60 RTS # call #41 - CLOSE WINDOW >9981 ; -- close window ] descr: ] Close window ] input: ] $94,$95 = window address ] calls: ] $9384 = clear window area ] $9316 = remove window from windows list ] $8e2e = switch output screen buffer ] $9994 = redraw windows ] $8e42 = switch visible screen buffer ,9981 20 84 93 JSR $9384 ; clear window area ,9984 20 16 93 JSR $9316 ; remove window from list ,9987 20 2e 8e JSR $8e2e ; switch output to back buffer ,998a 20 84 93 JSR $9384 ; clear window area ,998d 20 94 99 JSR $9994 ; redraw windows ,9990 20 42 8e JSR $8e42 ; switch visible screen ,9993 60 RTS # call #42 - REDRAW ALL WINDOWS >9994 ; -- redraw all windows ] descr: ] Redraw all windows ] calls: ] $8f93 = select window ] $92a5 = redraw window ] $93f7 = get previous window ,9994 ad 23 c0 LDA $c023 ; windows count ,9997 85 95 STA $95 ,9999 f0 1b BEQ $99b6 ; no windows visible ,999b 0a ASL ,999c 38 SEC ,999d e9 02 SBC #$02 ,999f a8 TAY ,99a0 b9 24 c0 LDA $c024,Y ; get last window ,99a3 aa TAX ,99a4 c8 INY ,99a5 b9 24 c0 LDA $c024,Y ,99a8 a8 TAY ,99a9 20 93 8f JSR $8f93 ; select window ,99ac 20 a5 92 JSR $92a5 ; redraw window ,99af 20 f7 93 JSR $93f7 ; get previous window ,99b2 c0 00 CPY #$00 ; end of list? ,99b4 d0 f3 BNE $99a9 ,99b6 60 RTS # call #45 - DRAW ZERO-TERMINATED TEXT LIST >99b7 ; -- draw zero-terminated text list ] descr: ] Draw zero terminated list of texts ] note: ] Each entry on the list is a structure as in $920e ] input: ] x,y = address ] $c000,$c001 = window position ] $c00f,$c010 = gadget position (or 0,0) ] calls: ] $920e = draw gadget text ,99b7 20 0e 92 JSR $920e ; draw text ,99ba c8 INY ; string length ,99bb 98 TYA ,99bc 18 CLC ,99bd 65 a5 ADC $a5 ; move string pointer to next string ,99bf 90 02 BCC $99c3 ,99c1 e6 a6 INC $a6 ,99c3 85 a5 STA $a5 ,99c5 a0 00 LDY #$00 ,99c7 b1 a5 LDA ($a5),Y ; get next string ,99c9 f0 07 BEQ $99d2 ; end of list ,99cb a6 a5 LDX $a5 ,99cd a4 a6 LDY $a6 ,99cf 18 CLC ,99d0 90 e5 BCC $99b7 ; draw next text ,99d2 60 RTS # call #46 - LOCATE WINDOW ON WINDOWS LIST >99d3 ; -- locale window on windows list ] descr: ] Locate window on windows list ] input: ] x,y = window address ] uses: ] $8e,$8f = address ] output: ] y = window offset on list ] $ff = not found ,99d3 86 8e STX $8e ; save window address ,99d5 84 8f STY $8f ,99d7 ae 23 c0 LDX $c023 ; windows list length ,99da f0 16 BEQ $99f2 ,99dc a0 fe LDY #$fe ,99de ca DEX ,99df 30 11 BMI $99f2 ,99e1 c8 INY ,99e2 c8 INY ,99e3 a5 8f LDA $8f ; compare window address with next address on list ,99e5 d9 25 c0 CMP $c025,Y ,99e8 d0 f4 BNE $99de ,99ea a5 8e LDA $8e ,99ec d9 24 c0 CMP $c024,Y ,99ef d0 ed BNE $99de ,99f1 60 RTS ,99f2 a0 ff LDY #$ff ; window not found ,99f4 60 RTS # call #58 - INITIALIZE GRAPHICS MODE >99f5 ; -- initialize graphics mode ] descr: ] Initialize graphics mode ] calls: ] $9a19 = blank screen ] $8cd1 = initialize vectors ] $8d8e = restore colors and preferences ] $8d26 = initialize video memory ] $b006 = install default menu ] $8712 = initialize cursor ,99f5 20 19 9a JSR $9a19 ; blank screen ,99f8 20 d1 8c JSR $8cd1 ; initialize vectors ,99fb 20 8e 8d JSR $8d8e ; restore colors and preferences ,99fe 18 CLC ,99ff 90 09 BCC $9a0a # call #47 - INITIALIZE GRAPHICS MODE AND PREFERENCES ] descr: ] Initialize graphics mode and preferences ] calls: ] $9a19 = blank screen ] $8cd1 = initialize vectors ] $8d83 = set default colors and preferences ] $8d26 = initialize video memory ] $b006 = install default menu ] $8712 = initialize cursor >9a01 ; -- initialize graphics mode and preferences ,9a01 20 19 9a JSR $9a19 ; blank screen ,9a04 20 d1 8c JSR $8cd1 ; initialize vectors ,9a07 20 83 8d JSR $8d83 ; set default colors and preferences ,9a0a 20 26 8d JSR $8d26 ; initialize video memory ,9a0d 20 06 b0 JSR $b006 ; install default menu ,9a10 4c 12 87 JMP $8712 ; initialize pointer # call #48 - DISABLE POINTER AND SWITCH TO TEXT MODE >9a13 ; -- disable pointer and switch to text mode ] descr: ] Disable pointer and switch to text mode ] calls: ] $9a13 = disable pointer and remove pointer ISR ] $8d4a = switch to text mode ,9a13 20 a1 87 JSR $87a1 ; disable pointer and remove pointer ISR ,9a16 4c 4a 8d JMP $8d4a ; switch to text mode >9a19 ; -- blank screen ] descr: ] Blank screen ] calls: ] $9a22 = wait for vertical retrace ,9a19 20 22 9a JSR $9a22 ; wait for vertical retrace ,9a1c a9 0b LDA #$0b ; blank screen ,9a1e 8d 11 d0 STA $d011 ,9a21 60 RTS >9a22 ; -- wait for vertical retrace ] descr: ] Wait for vertical retrace ,9a22 78 SEI ; disable interrupts ,9a23 ad 12 d0 LDA $d012 ; wait for raster line $fb ,9a26 c9 fb CMP #$fb ,9a28 90 f9 BCC $9a23 ,9a2a 58 CLI ; enable interrupts ,9a2b 60 RTS ; -- unused memory :9a2c 00 00 00 00 00 00 00 00 :9a34 00 00 00 00 00 00 00 00 :9a3c 00 00 00 00 00 00 00 00 :9a44 00 00 00 00 00 00 00 00 :9a4c 00 00 00 00 00 00 00 00 :9a54 00 00 00 00 00 00 00 00 :9a5c 00 00 00 00 00 00 00 00 :9a64 00 00 00 00 00 00 00 00 :9a6c 00 00 00 00 00 00 00 00 :9a74 00 00 00 00 00 00 00 00 :9a7c 00 00 00 00 >9a80 ; -- notepad part 2, relocated to $1080 >9e00 ; -- memory mapped to $de00 >a000 ; -- CLOSE button image :a000 0b 0b 07 02 7f e0 7f e0 :a008 40 20 5f a0 5f a0 59 a0 :a010 59 a0 5f a0 5f a0 40 20 :a018 7f e0 7f e0 >a01c ; -- TO BACK button image :a01c 0c 0b 07 02 7f f0 7f f0 :a024 40 f0 40 f0 40 10 43 d0 :a02c 43 d0 7b d0 7b d0 78 10 :a034 7f f0 7f f0 >a038 ; -- RESIZE button image :a038 09 09 07 02 ff c0 ff c0 :a040 c7 c0 d7 c0 c0 c0 f6 c0 :a048 f6 c0 f0 c0 ff c0 ff c0 >a050 ; -- drag bar segment image :a050 1f 0b 07 04 ff ff ff ff :a058 00 00 00 00 ff ff ff ff :a060 00 00 00 00 ff ff ff ff :a068 00 00 00 00 ff ff ff ff :a070 00 00 00 00 ff ff ff ff :a078 00 00 00 00 ff ff ff ff :a080 ff ff ff ff >a084 ; -- arrow down with frame image :a084 0e 0d 07 02 ff fe 80 02 :a08c 80 02 80 02 bf fa 9f f2 :a094 8f e2 87 c2 83 82 81 02 :a09c 80 02 80 02 80 02 ff fe >a0a4 ; -- arrow up with frame image :a0a4 0e 0d 07 02 ff fe 80 02 :a0ac 80 02 80 02 81 02 83 82 :a0b4 87 c2 8f e2 9f f2 bf fa :a0bc 80 02 80 02 80 02 ff fe >a0c4 ; -- short arrow down image :a0c4 0b 05 07 02 ff e0 7f c0 :a0cc 3f 80 1f 00 0e 00 04 00 >a0d4 ; -- short arrow up image :a0d4 0b 05 07 02 04 00 0e 00 :a0dc 1f 00 3f 80 7f c0 ff e0 >a0e4 ; -- long arrow up image :a0e4 0c 09 07 02 02 00 07 00 :a0ec 0f 80 1f c0 3f e0 7f f0 :a0f4 ff f8 1f c0 1f c0 1f c0 >a0fc ; -- long arrow down image :a0fc 0c 09 07 02 1f c0 1f c0 :a104 1f c0 ff f8 7f f0 3f e0 :a10c 1f c0 0f 80 07 00 02 00 >a114 ; -- watch image :a114 2f 0c 07 06 00 00 03 e0 :a11c 00 00 00 00 ef fb 00 00 :a124 00 07 9c 1c e0 00 00 78 :a12c b0 86 9e 00 ff 88 b0 86 :a134 85 ff 84 88 e0 83 84 21 :a13c bc 88 e1 83 b5 ad 84 88 :a144 e3 03 84 21 ff 88 b6 06 :a14c 85 ff 00 78 b0 06 9e 00 :a154 00 07 9c 1c e0 00 00 00 :a15c ef fb 00 00 00 00 03 e0 :a164 00 00 >a166 ; -- alarm image :a166 1f 0d 07 04 00 00 04 00 :a16e 00 24 42 00 00 e3 21 00 :a176 03 e1 99 00 0f e1 88 80 :a17e ff f0 cc 80 ff e8 00 00 :a186 ff e8 00 00 ff f0 cc 80 :a18e 0f e1 88 80 03 e1 99 00 :a196 00 e2 21 00 00 24 42 00 :a19e 00 00 04 00 >a1a2 ; -- charset pixel data :a1a2 70 08 70 70 88 70 70 70 :a1aa 70 70 88 00 00 00 30 04 :a1b2 00 40 a0 50 20 00 30 40 :a1ba 20 80 00 00 00 00 00 00 :a1c2 70 40 60 f0 10 f0 70 f0 :a1ca 70 70 00 00 00 00 00 60 :a1d2 38 00 80 00 10 00 60 00 :a1da 80 80 20 80 80 00 00 00 :a1e2 00 00 00 00 80 00 00 00 :a1ea 00 00 00 40 18 80 20 00 :a1f2 00 30 f0 70 f0 f0 f0 70 :a1fa 88 80 10 88 80 82 84 70 :a202 f0 70 f0 78 f8 88 88 82 :a20a 88 88 fc 00 00 00 00 88 :a212 08 08 08 88 80 80 08 88 :a21a 88 d8 00 00 00 40 04 00 :a222 e0 a0 50 70 00 48 40 40 :a22a 40 00 00 00 00 00 00 88 :a232 c0 90 10 30 80 80 10 88 :a23a 88 00 00 00 00 00 90 44 :a242 00 80 00 10 00 80 00 80 :a24a 00 00 80 80 00 00 00 00 :a252 00 00 00 80 00 00 00 00 :a25a 00 00 80 20 40 70 00 00 :a262 48 88 88 88 80 80 88 88 :a26a 80 10 90 80 c6 c4 88 88 :a272 88 88 80 20 88 88 82 88 :a27a 88 04 00 00 00 00 88 08 :a282 08 08 88 80 80 08 88 88 :a28a a8 70 20 00 8c 08 00 e0 :a292 a0 f8 80 88 50 80 80 20 :a29a a8 20 00 00 00 08 98 40 :a2a2 10 10 50 80 80 10 88 88 :a2aa 00 00 20 00 80 10 9c 60 :a2b2 e0 70 70 60 80 60 e0 80 :a2ba 20 90 80 ec e0 60 60 60 :a2c2 a0 70 80 90 88 92 88 90 :a2ca f0 80 40 40 f8 20 00 84 :a2d2 88 80 88 80 80 80 88 80 :a2da 10 a0 80 aa a4 88 88 88 :a2e2 88 80 20 88 88 82 50 88 :a2ea 08 00 00 00 00 00 00 70 :a2f2 30 70 70 70 00 70 70 88 :a2fa 40 00 00 80 08 00 40 00 :a302 50 60 10 20 00 80 20 70 :a30a 20 00 00 00 10 a8 40 20 :a312 60 90 e0 f0 20 70 78 80 :a31a 40 40 00 40 20 9c 10 90 :a322 80 90 90 c0 90 90 80 20 :a32a a0 80 92 90 90 90 90 c0 :a332 80 c0 90 88 92 50 90 20 :a33a 80 e0 40 20 60 00 84 f0 :a342 80 88 e0 e0 98 f8 80 10 :a34a c0 80 92 94 88 88 88 88 :a352 70 20 88 88 92 20 50 10 :a35a 00 00 00 00 88 08 80 08 :a362 08 08 88 08 88 08 88 60 :a36a f8 00 8c 90 00 40 00 f8 :a372 10 20 54 00 80 20 f8 f8 :a37a 00 f8 00 20 c8 40 40 10 :a382 f8 10 88 40 88 08 00 00 :a38a 80 f0 20 20 80 70 90 80 :a392 90 f0 80 90 90 80 20 c0 :a39a 80 92 90 90 90 90 80 60 :a3a2 80 90 88 92 20 90 40 80 :a3aa 40 40 20 f8 00 fc 88 80 :a3b2 88 80 80 88 88 80 10 a0 :a3ba 80 82 8c 88 f0 88 f0 08 :a3c2 20 88 88 aa 50 20 20 00 :a3ca 00 00 00 88 08 80 08 08 :a3d2 08 88 08 88 08 00 40 00 :a3da 00 40 60 00 00 00 50 e0 :a3e2 40 88 00 40 40 70 20 00 :a3ea 00 00 40 88 40 80 10 10 :a3f2 10 88 80 88 08 00 00 40 :a3fa 00 40 00 44 90 90 80 90 :a402 80 80 90 90 80 20 a0 80 :a40a 92 90 90 90 90 80 10 80 :a412 90 50 92 50 90 80 80 40 :a41a 40 20 60 00 84 88 88 88 :a422 80 80 88 88 80 10 90 80 :a42a 82 84 88 80 88 90 08 20 :a432 88 50 c6 88 20 40 00 00 :a43a 00 00 70 08 70 70 08 70 :a442 70 08 70 70 00 70 20 00 :a44a 30 20 00 40 00 50 40 88 :a452 74 00 20 80 a8 20 40 00 :a45a 80 80 70 e0 f0 e0 10 e0 :a462 70 80 70 70 80 40 20 f0 :a46a 80 20 38 78 e0 70 70 70 :a472 80 70 90 80 20 90 40 92 :a47a 90 60 e0 70 80 e0 60 70 :a482 20 6c 88 70 f0 80 78 40 :a48a 20 20 00 84 f0 70 f0 f0 :a492 80 70 88 80 e0 88 e0 82 :a49a 84 70 80 70 88 f0 20 78 :a4a2 20 82 88 20 fc 00 00 00 :a4aa 00 00 00 00 00 00 00 00 :a4b2 00 00 00 00 00 00 80 00 :a4ba 00 00 00 00 00 00 00 00 :a4c2 00 00 00 00 00 40 00 00 :a4ca 00 00 00 00 00 00 00 00 :a4d2 00 00 00 00 80 00 00 00 :a4da 00 00 00 00 00 00 00 00 :a4e2 10 00 00 20 00 00 00 00 :a4ea 00 80 10 00 00 00 00 00 :a4f2 00 00 10 00 40 00 80 00 :a4fa 00 00 00 00 00 00 00 00 :a502 00 00 00 00 00 00 00 00 :a50a 00 00 18 00 00 00 00 00 :a512 00 00 00 00 00 00 00 00 :a51a 00 00 00 00 00 00 00 00 :a522 00 00 00 00 00 00 00 00 :a52a 00 00 00 00 00 00 00 00 :a532 00 00 00 00 80 00 00 00 :a53a 00 00 00 00 00 00 00 00 :a542 00 00 00 00 00 00 00 00 :a54a 00 00 00 00 00 00 00 60 :a552 00 00 c0 00 00 00 00 00 :a55a 80 10 00 00 00 00 00 00 :a562 00 60 00 00 00 00 00 00 :a56a 00 00 00 00 00 00 00 00 :a572 00 00 00 00 00 00 00 00 :a57a 00 00 00 00 00 00 00 00 :a582 00 00 00 00 00 00 00 >a589 ; -- character width table :a589 04 04 04 04 04 04 04 04 :a591 04 04 04 04 04 01 05 05 :a599 01 02 02 04 03 04 05 01 :a5a1 02 02 04 04 01 04 00 04 :a5a9 04 02 03 03 04 03 04 03 :a5b1 04 04 00 01 02 03 02 03 :a5b9 05 04 03 03 03 03 02 03 :a5c1 03 00 02 03 01 06 03 03 :a5c9 03 03 02 03 02 03 04 06 :a5d1 04 03 03 01 04 01 04 04 :a5d9 00 05 04 04 04 03 03 04 :a5e1 04 00 03 04 02 06 05 04 :a5e9 04 04 04 04 04 04 04 06 :a5f1 04 04 05 06 03 04 01 >a5f8 ; -- sprite - pointer 1 :a5f8 00 00 00 7c 00 00 7c 00 :a600 00 78 00 00 7c 00 00 6e :a608 00 00 07 00 00 03 80 00 :a610 01 c0 00 00 80 00 00 00 :a618 00 00 00 00 00 00 00 00 :a620 00 00 00 00 00 00 00 00 :a628 00 00 00 00 00 00 00 00 :a630 00 00 00 00 00 00 00 00 >a638 ; -- sprite - pointer 2 :a638 fc 00 00 82 00 00 82 00 :a640 00 84 00 00 82 00 00 91 :a648 00 00 68 80 00 04 40 00 :a650 02 20 00 01 40 00 00 80 :a658 00 00 00 00 00 00 00 00 :a660 00 00 00 00 00 00 00 00 :a668 00 00 00 00 00 00 00 00 :a670 00 00 00 00 00 00 00 00 >a678 ; -- sprite - top left corner :a678 ff 00 00 80 00 00 80 00 :a680 00 80 00 00 80 00 00 80 :a688 00 00 80 00 00 00 00 00 :a690 00 00 00 00 00 00 00 00 :a698 00 00 00 00 00 00 00 00 :a6a0 00 00 00 00 00 00 00 00 :a6a8 00 00 00 00 00 00 00 00 :a6b0 00 00 00 00 00 00 00 00 >a6b8 ; -- sprite - top right corner :a6b8 ff 00 00 01 00 00 01 00 :a6c0 00 01 00 00 01 00 00 01 :a6c8 00 00 01 00 00 00 00 00 :a6d0 00 00 00 00 00 00 00 00 :a6d8 00 00 00 00 00 00 00 00 :a6e0 00 00 00 00 00 00 00 00 :a6e8 00 00 00 00 00 00 00 00 :a6f0 00 00 00 00 00 00 00 00 >a6f8 ; -- sprite - bottom left corner :a6f8 80 00 00 80 00 00 80 00 :a700 00 80 00 00 80 00 00 80 :a708 00 00 ff 00 00 00 00 00 :a710 00 00 00 00 00 00 00 00 :a718 00 00 00 00 00 00 00 00 :a720 00 00 00 00 00 00 00 00 :a728 00 00 00 00 00 00 00 00 :a730 00 00 00 00 00 00 00 00 >a738 ; -- sprite - bottom right corner :a738 01 00 00 01 00 00 01 00 :a740 00 01 00 00 01 00 00 01 :a748 00 00 ff 00 00 00 00 00 :a750 00 00 00 00 00 00 00 00 :a758 00 00 00 00 00 00 00 00 :a760 00 00 00 00 00 00 00 00 :a768 00 00 00 00 00 00 00 00 :a770 00 00 00 00 00 00 00 00 >a778 ; -- sprite - text cursor :a778 80 00 00 80 00 00 80 00 :a780 00 80 00 00 80 00 00 80 :a788 00 00 80 00 00 80 00 00 :a790 80 00 00 80 00 00 00 00 :a798 00 00 00 00 00 00 00 00 :a7a0 00 00 00 00 00 00 00 00 :a7a8 00 00 00 00 00 00 00 00 :a7b0 00 00 00 00 00 00 00 00 >a7b8 ; -- default menu texts :a7b8 c9 ce c6 cf 00 ; INFO :a7bd d3 d9 d3 d4 c5 cd 00 ; SYSTEM :a7c4 d0 d2 cf ca c5 c3 d4 00 ; PROJECT :a7cc d5 d4 c9 cc c9 d4 c9 c5 ; UTILITIES :a7d4 d3 00 :a7d6 c3 cc cf c3 cb 00 ; CLOCK :a7dc c4 c5 d3 cb d4 cf d0 00 ; DESKTOP :a7e4 d6 c5 d2 d3 c9 cf ce 00 ; VERSION :a7ec c2 c1 d3 c9 c3 00 ; BASIC :a7f2 c6 c9 ce c1 cc a0 cb c9 ; FINAL KILL :a7fa cc cc 00 :a7fd c6 d2 c5 c5 da c5 d2 00 ; FREEZER :a805 d2 c5 c4 d2 c1 d7 00 ; REDRAW :a80c ce cf d4 c5 d0 c1 c4 00 ; NOTEPAD :a814 c4 cc c9 ce cb 00 ; DLINK :a81a d4 cc c9 ce cb 00 ; TLINK :a820 d0 d2 c5 c6 c5 d2 c5 ce ; PREFERENCES :a828 c3 c5 d3 00 :a82c c2 c1 d3 c9 c3 20 d0 d2 ; BASIC PREFS :a834 c5 c6 d3 00 :a838 c3 c1 cc c3 d5 cc c1 d4 ; CALCULATOR :a840 cf d2 00 :a843 c4 c9 d3 cb 00 ; DISK :a848 d4 c1 d0 c5 00 ; TAPE :a84d d3 c5 d4 d4 c9 ce c7 d3 ; SETTINGS :a855 00 :a856 c4 c5 d3 cb d4 cf d0 a0 ; DESKTOP V1.0 :a85e d6 31 2e 30 00 >a863 ; -- default menu, relocated to $c060 :a863 6a c0 92 c0 b8 a7 20 11 ; $c060 - menu INFO :a86b 30 00 :a86d 74 c0 a2 c0 bd a7 30 21 ; $c06a - menu SYSTEM :a875 38 00 :a877 7e c0 c2 c0 c4 a7 30 19 ; $c074 - menu PROJECT :a87f 38 00 :a881 88 c0 da c0 cc a7 30 29 ; $c07e - menu UTILITIES :a889 48 00 :a88b 00 00 02 c1 d6 a7 28 19 ; $c088 - menu CLOCK :a893 38 00 :a895 9a c0 dc a7 00 00 00 00 ; $c092 - item DESKTOP :a89d 00 00 e4 a7 00 00 00 00 ; $c09a - item VERSION :a8a5 aa c0 ec a7 00 00 00 00 ; $c0a2 - item BASIC :a8ad b2 c0 f2 a7 00 00 00 00 ; $c0aa - item FINAL KILL :a8b5 ba c0 fd a7 00 00 00 00 ; $c0b2 - item FREEZER :a8bd 00 00 05 a8 00 00 00 00 ; $c0ba - item REDRAW :a8c5 ca c0 0c a8 00 00 00 00 ; $c0c2 - item NOTEPAD :a8cd d2 c0 14 a8 00 00 00 00 ; $c0ca - item DLINK :a8d5 00 00 1a a8 00 00 00 00 ; $c0d2 - item TLINK :a8dd e2 c0 20 a8 00 00 00 00 ; $c0da - item PREFERENCES :a8e5 ea c0 2c a8 00 00 00 00 ; $c0e2 - item BASIC PREFS :a8ed f2 c0 38 a8 00 00 00 00 ; $c0ea - item CALCULATOR :a8f5 fa c0 43 a8 00 00 00 00 ; $c0f2 - item DISK :a8fd 00 00 48 a8 00 00 00 00 ; $c0fa - item TAPE :a905 0d c1 20 c1 00 00 20 00 ; $c102 - item TIME :a90d 08 1f 7b :a910 18 c1 2a c1 00 00 20 00 ; $c10d - item ALARM :a918 06 1f 7b :a91b 00 00 4d a8 00 00 00 00 ; $c118 - item SETTINGS :a923 d4 c9 cd c5 7c 20 20 20 ; $c120 - text TIME~ :a92b 20 00 :a92d c1 cc c1 d2 cd 20 20 20 ; $c12a - text ALARM :a935 20 00 >a937 ; -- message box data, relocated to $c134 :a937 00 00 00 00 00 0b 00 00 ; $c134 - left msgbox button gadget :a93f 1d 00 00 00 00 00 00 00 :a947 00 00 00 00 00 0b 00 00 ; $c144 - right msgbox button gadget :a94f 1d 00 00 00 00 00 00 ff :a957 cf cb 00 ; $c154 - OK, default msgbox button text :a95a c3 c1 ce c3 c5 cc 00 ; $c157 - CANCEL, default msgbox button text >a961 ; -- switch FCIII ROM and LOAD, relocated to $c15e ,a961 8d ff df STA $dfff ; switch FCIII ROM bank ,a964 a9 00 LDA #$00 ; clear verify flag ,a966 20 d5 ff JSR $ffd5 ; call LOAD procedure ,a969 4c 71 c1 JMP $c171 >a96c ; -- switch FCIII ROM and SAVE, relocated to $c169 ,a96c 8d ff df STA $dfff ; switch FCIII ROM bank ,a96f a5 f7 LDA $f7 ; indirect start address on zero page ,a971 20 d8 ff JSR $ffd8 ; call SAVE procedure ,a974 a9 41 LDA #$41 ; $c171 ,a976 8d ff df STA $dfff ; restore FCIII ROM bank ,a979 60 RTS >a97a ; -- unused :a97a 00 00 00 00 00 00 >a980 ; -- notepad part 1, relocated to $0e00 # call #43 - SET MENU ADDRESS AND DRAW MENU BAR >ac00 ; -- set menu address and draw menu bar ] descr: ] Set menu address and draw menu bar ] input: ] x,y = menu address ] uses: ] $94,$95 = menu pointer ] call: ] $ac20 = draw menu ] $8e2e = switch output screen buffer ] output: ] $03ce,$03cf = menu address ,ac00 8e ce 03 STX $03ce ; save menu address ,ac03 8c cf 03 STY $03cf ,ac06 86 94 STX $94 ; reset menu pointer ,ac08 84 95 STY $95 ,ac0a 20 20 ac JSR $ac20 ; draw menu ,ac0d 20 2e 8e JSR $8e2e ; switch output screen buffer ,ac10 ae ce 03 LDX $03ce ,ac13 ac cf 03 LDY $03cf ,ac16 86 94 STX $94 ; reset menu pointer ,ac18 84 95 STY $95 ,ac1a 20 20 ac JSR $ac20 ; draw menu ,ac1d 4c 2e 8e JMP $8e2e ; switch output screen buffer >ac20 ; -- draw menu bar ] descr: ] Draw menu bar ] input: ] $94,$95 = menu address ] uses: ] $9f = position x ] $8c = position x - bit 8 ] calls: ] $815d = set drawing position ] $815f = set drawing position ] $8233 = draw filled box ] $840a = draw text ,ac20 a2 00 LDX #$00 ,ac22 a0 00 LDY #$00 ,ac24 20 5d 81 JSR $815d ; set drawing position to 0,0 ,ac27 a2 9f LDX #$9f ,ac29 a0 09 LDY #$09 ,ac2b 20 33 82 JSR $8233 ; box 159x9 ,ac2e a2 a0 LDX #$a0 ,ac30 a0 00 LDY #$00 ,ac32 84 8c STY $8c ; clear position x bit 8 ,ac34 20 5d 81 JSR $815d ; set drawing position to 160,0 ,ac37 a2 9f LDX #$9f ,ac39 a0 09 LDY #$09 ,ac3b 20 33 82 JSR $8233 ; box 159x9 ,ac3e a9 02 LDA #$02 ; set position x to 2 ,ac40 85 9f STA $9f ,ac42 a5 8c LDA $8c ,ac44 a6 9f LDX $9f ,ac46 a0 01 LDY #$01 ,ac48 20 5f 81 JSR $815f ; move drawing position ,ac4b a0 06 LDY #$06 ,ac4d 18 CLC ,ac4e b1 94 LDA ($94),Y ; menu title width ,ac50 65 9f ADC $9f ; move saved position x ,ac52 90 02 BCC $ac56 ,ac54 e6 8c INC $8c ,ac56 85 9f STA $9f ,ac58 a0 04 LDY #$04 ,ac5a b1 94 LDA ($94),Y ; menu title ,ac5c aa TAX ,ac5d c8 INY ,ac5e b1 94 LDA ($94),Y ,ac60 f0 4e BEQ $acb0 ,ac62 a8 TAY ,ac63 a9 01 LDA #$01 ,ac65 20 0a 84 JSR $840a ; draw menu title ,ac68 a0 00 LDY #$00 ,ac6a b1 94 LDA ($94),Y ; next menu ,ac6c aa TAX ,ac6d c8 INY ,ac6e b1 94 LDA ($94),Y ,ac70 f0 3e BEQ $acb0 ,ac72 86 94 STX $94 ; move menu pointer to next menu ,ac74 85 95 STA $95 ,ac76 d0 ca BNE $ac42 ; draw next menu title ,ac78 60 RTS >ac79 ; -- highlight item ] descr: ] Highlight menu title or menu item under cursor ] input: ] x = combined color (attribute) to use ] $9f = line number (in char box units) ] $92 = active output screen buffer ] $96 = width in pixels ] $8c,$8b = position x in pixels ] uses: ] $c3,$a3,$a4,$8d ] calls: ] $8d69 = multiply ,ac79 86 c3 STX $c3 ; save color ,ac7b a2 28 LDX #$28 ,ac7d a5 9f LDA $9f ; color memory line number ,ac7f a8 TAY ,ac80 20 69 8d JSR $8d69 ; multiply (* 40) ,ac83 a9 04 LDA #$04 ; $0400 - color memory for screen buffer $2000 ,ac85 a6 92 LDX $92 ; active output screen buffer ,ac87 e0 20 CPX #$20 ,ac89 f0 02 BEQ $ac8d ,ac8b a9 60 LDA #$60 ; $6000 - color memory for screen buffer $4000 ,ac8d 18 CLC ,ac8e 65 a4 ADC $a4 ; add line offset ,ac90 85 a4 STA $a4 ,ac92 a5 96 LDA $96 ; menu or item width ,ac94 4a LSR ,ac95 4a LSR ,ac96 4a LSR ,ac97 aa TAX ; width in char boxes ,ac98 f0 16 BEQ $acb0 ,ac9a a5 8c LDA $8c ; left edge ,ac9c 4a LSR ,ac9d 4a LSR ,ac9e 4a LSR ; line offset in chars ,ac9f a4 8b LDY $8b ; left edge, msb ,aca1 f0 02 BEQ $aca5 ,aca3 09 20 ORA #$20 ,aca5 85 8d STA $8d ; left edge / 8 ,aca7 a8 TAY ,aca8 a5 c3 LDA $c3 ; attribute to use ,acaa 91 a3 STA ($a3),Y ; update color memory ,acac c8 INY ,acad ca DEX ,acae d0 fa BNE $acaa ; next char box ,acb0 60 RTS >acb1 ; -- draw drop-down menu ] descr: ] Draw drop-down menu ] input: ] $8b,$8c = position x ] $94,$95 = menu address ] $c014 = scratch area ] uses: ] $9b,$9c = menu item address ] $9e ] $a3,$a4 = scratch area pointer ] calls: ] $815f = set drawing position ] $8233 = foreground filled box ] $90a4 = save drawing position address ] $840a = draw text ] $af6a = gray-out text ] output: ] $96 = menu width ] $8f = menu height ] $c010 = menu item count ,acb1 a9 00 LDA #$00 ,acb3 8d 10 c0 STA $c010 ; menu item index ,acb6 a5 8b LDA $8b ,acb8 a6 8c LDX $8c ; drop-down menu position x ,acba a0 08 LDY #$08 ,acbc 20 5f 81 JSR $815f ; set drawing position ,acbf a0 08 LDY #$08 ,acc1 b1 94 LDA ($94),Y ; drop-down menu width ,acc3 85 96 STA $96 ,acc5 aa TAX ,acc6 ca DEX ,acc7 88 DEY ,acc8 b1 94 LDA ($94),Y ; drop-down menu height ,acca a8 TAY ,accb 85 8f STA $8f ,accd 20 33 82 JSR $8233 ; draw menu box ,acd0 a0 02 LDY #$02 ,acd2 b1 94 LDA ($94),Y ; get first menu item ,acd4 85 9b STA $9b ,acd6 c8 INY ,acd7 b1 94 LDA ($94),Y ,acd9 f0 53 BEQ $ad2e ; item list empty ,acdb 85 9c STA $9c ,acdd a5 8b LDA $8b ,acdf a6 8c LDX $8c ; menu left edge+2 ,ace1 e8 INX ,ace2 e8 INX ,ace3 a0 09 LDY #$09 ,ace5 20 5f 81 JSR $815f ; set drawing position ,ace8 a5 fd LDA $fd ; drawing position bit number ,acea 85 9e STA $9e ; -- menu item loop ,acec 20 a4 90 JSR $90a4 ; save drawing position address ,acef ee 10 c0 INC $c010 ; menu item index ,acf2 a0 02 LDY #$02 ,acf4 b1 9b LDA ($9b),Y ; item text ,acf6 aa TAX ,acf7 c8 INY ,acf8 b1 9b LDA ($9b),Y ,acfa f0 20 BEQ $ad1c ; no item text ,acfc a8 TAY ,acfd a9 01 LDA #$01 ,acff 20 0a 84 JSR $840a ; put text ,ad02 a0 06 LDY #$06 ,ad04 b1 9b LDA ($9b),Y ; item ENABLED flag ,ad06 29 01 AND #$01 ,ad08 a2 00 LDX #$00 ,ad0a ac 14 c0 LDY $c014 ; scratch area ,ad0d 86 a3 STX $a3 ,ad0f 84 a4 STY $a4 ,ad11 ac 10 c0 LDY $c010 ; menu item index ,ad14 91 a3 STA ($a3),Y ; save ENABLED flag in scratch area ,ad16 aa TAX ,ad17 d0 03 BNE $ad1c ,ad19 20 6a af JSR $af6a ; gray-out text ,ad1c a5 9e LDA $9e ,ad1e 85 fd STA $fd ; restore drawing position bit number ,ad20 a0 00 LDY #$00 ; get next menu item ,ad22 b1 9b LDA ($9b),Y ,ad24 aa TAX ,ad25 c8 INY ,ad26 b1 9b LDA ($9b),Y ,ad28 86 9b STX $9b ,ad2a 85 9c STA $9c ,ad2c d0 be BNE $acec ,ad2e 60 RTS >ad2f ; -- handle drop-down menu activated ] descr: ] Handle drop-down menu activated ] input: ] $8b,$8c = position x ] $8d = left edge in chars ] $8e = menu title width in chars ] $b6 = cursor position y ] $c011 = color for inactive item ] $c012 = color for active item ] uses: ] $96 = menu width ] $8f = menu height ] $a6 = right edge in chars ] $c00f = highlighted menu item ] $c010 = menu item count ] $a5 = cursor position x in chars ] $a3,$a4 = scratch area pointer ] $9f = highlight item index ] calls: ] $acb1 = draw drop-down menu ] $adda = get cursor position x in chars ] $ac79 = highlight menu item ,ad2f 20 b1 ac JSR $acb1 ; draw menu ,ad32 a9 00 LDA #$00 ,ad34 8d 0f c0 STA $c00f ,ad37 18 CLC ,ad38 a5 96 LDA $96 ; menu width ,ad3a 4a LSR ,ad3b 4a LSR ,ad3c 4a LSR ,ad3d 65 8d ADC $8d ; left edge in chars ,ad3f 85 a6 STA $a6 ; right edge in chars ; -- drop-down menu handle loop ,ad41 20 da ad JSR $adda ; get cursor position x in chars ,ad44 a5 b6 LDA $b6 ,ad46 c9 08 CMP #$08 ,ad48 90 6a BCC $adb4 ; cursor over menu bar ,ad4a a5 a5 LDA $a5 ; cursor position ,ad4c c5 8d CMP $8d ; left edge ,ad4e 90 32 BCC $ad82 ; cursor outside menu ,ad50 a5 a5 LDA $a5 ,ad52 c5 a6 CMP $a6 ; right edge ,ad54 b0 2c BCS $ad82 ; cursor outside ,ad56 18 CLC ,ad57 a5 8f LDA $8f ; menu height ,ad59 69 0a ADC #$0a ; + menu bar height ,ad5b c5 b6 CMP $b6 ; cursor position y ,ad5d 90 23 BCC $ad82 ; cursor outside menu ,ad5f a5 b6 LDA $b6 ,ad61 4a LSR ,ad62 4a LSR ,ad63 4a LSR ; item number under cursor ,ad64 cd 0f c0 CMP $c00f ; previous item number ,ad67 f0 38 BEQ $ada1 ,ad69 cd 10 c0 CMP $c010 ; menu item count ,ad6c f0 02 BEQ $ad70 ,ad6e b0 12 BCS $ad82 ; cursor below last item ,ad70 a8 TAY ; item index under cursor ,ad71 a2 00 LDX #$00 ,ad73 86 a3 STX $a3 ,ad75 ae 14 c0 LDX $c014 ,ad78 86 a4 STX $a4 ; pointer to scratch area ,ad7a b1 a3 LDA ($a3),Y ; get item ENABLED flag ,ad7c aa TAX ,ad7d 98 TYA ,ad7e e0 00 CPX #$00 ,ad80 d0 02 BNE $ad84 ,ad82 a9 00 LDA #$00 ; item disabled, select none ,ad84 ae 0f c0 LDX $c00f ,ad87 8d 0f c0 STA $c00f ; select item under cursor ,ad8a 86 9f STX $9f ; previously active item ,ad8c f0 06 BEQ $ad94 ,ad8e ae 11 c0 LDX $c011 ; color for inactive item ,ad91 20 79 ac JSR $ac79 ; remove item highlight ,ad94 ad 0f c0 LDA $c00f ,ad97 f0 08 BEQ $ada1 ; no item activated ,ad99 85 9f STA $9f ,ad9b ae 12 c0 LDX $c012 ; color for active item ,ad9e 20 79 ac JSR $ac79 ; highlight item ,ada1 ad c8 03 LDA $03c8 ,ada4 f0 9b BEQ $ad41 ; loop until button released ,ada6 ad 0f c0 LDA $c00f ; active item ,ada9 f0 08 BEQ $adb3 ; no item active ,adab 85 9f STA $9f ,adad ae 11 c0 LDX $c011 ; color for inactive item ,adb0 20 79 ac JSR $ac79 ; remove item highlight ,adb3 60 RTS ; -- handle pull-down menu - cursor over menu bar ,adb4 ad 0f c0 LDA $c00f ; previously active item ,adb7 85 9f STA $9f ,adb9 f0 0b BEQ $adc6 ,adbb ae 11 c0 LDX $c011 ; inactive item color ,adbe 20 79 ac JSR $ac79 ; remove item highlight ,adc1 a9 00 LDA #$00 ; set no active item ,adc3 8d 0f c0 STA $c00f ,adc6 20 da ad JSR $adda ; get cursor x position in chars ,adc9 c5 8d CMP $8d ,adcb 90 e6 BCC $adb3 ; cursor outside menu title, return ,adcd a5 8e LDA $8e ,adcf 18 CLC ,add0 65 8d ADC $8d ,add2 c5 a5 CMP $a5 ,add4 f0 dd BEQ $adb3 ,add6 90 db BCC $adb3 ,add8 b0 c7 BCS $ada1 ; cursor over menu title, loop >adda ; -- get cursor position x in chars ] descr: ] Get cursor position x in chars ] input: ] $b4,$b5 = cursor position x ] output: ] $a5 = cursor position x / 8 ,adda a5 b4 LDA $b4 ; cursor position x ,addc 4a LSR ,addd 4a LSR ,adde 4a LSR ,addf a6 b5 LDX $b5 ; cursor position x - msb ,ade1 f0 02 BEQ $ade5 ,ade3 09 20 ORA #$20 ,ade5 85 a5 STA $a5 ; cursor position x / 8 ,ade7 60 RTS # call #3c - HANDLE MENU BAR CLICKED >ade8 ; -- handle menu bar clicked ] descr: ] Handle menu bar clicked ] input: ] $b4,$b5 = cursor position x ] $b6 = cursor position y ] $c019 = foreground color ] $c01a = background color ] $c017 = pointer color 1 ] $03ce,$03cf = menu start address ] uses: ] $c00f = selected item index ] $c011 = inactive item color ] $c012 = active item color ] $94,$95 = menu pointer ] $9b,$9c = menu item pointer ] $96 = menu title width ] $c3,$9f ] $8c,$8b = menu title left edge ] $8e = menu title width in chars ] calls: ] $ac79 = highlight menu title ] $af4b = save area under drop-down menu ] $ad2f = handle drop-down menu activated ] $af51 = restore area under drop-down menu ,ade8 a5 b6 LDA $b6 ; cursor position y ,adea c9 08 CMP #$08 ,adec 90 03 BCC $adf1 ,adee 4c 9d ae JMP $ae9d ; cursor outside menu bar ,adf1 ad 19 c0 LDA $c019 ; foreground color ,adf4 0a ASL ,adf5 0a ASL ,adf6 0a ASL ,adf7 0a ASL ,adf8 0d 1a c0 ORA $c01a ; background color ,adfb 8d 11 c0 STA $c011 ; save inactive item color ,adfe ad 17 c0 LDA $c017 ; pointer color 1 ,ae01 0a ASL ,ae02 0a ASL ,ae03 0a ASL ,ae04 0a ASL ,ae05 0d 1a c0 ORA $c01a ; background color ,ae08 8d 12 c0 STA $c012 ; save active item color ,ae0b ae ce 03 LDX $03ce ; menu start address ,ae0e ac cf 03 LDY $03cf ,ae11 86 94 STX $94 ; menu pointer ,ae13 84 95 STY $95 ,ae15 a9 00 LDA #$00 ,ae17 85 c3 STA $c3 ; menu hit test position x - bit 8 ,ae19 85 8b STA $8b ; menu title left edge - msb ,ae1b 85 8c STA $8c ; menu title left edge ,ae1d 85 9f STA $9f ; line number 0 for highlight menu title ,ae1f a0 06 LDY #$06 ,ae21 18 CLC ,ae22 b1 94 LDA ($94),Y ; menu title width ,ae24 aa TAX ,ae25 65 8c ADC $8c ; add to current position ,ae27 90 02 BCC $ae2b ,ae29 e6 c3 INC $c3 ,ae2b a4 c3 LDY $c3 ,ae2d c4 b5 CPY $b5 ; menu title right edge, bit 8 vs cursor position bit 8 ,ae2f 90 08 BCC $ae39 ; cursor on right ,ae31 d0 1c BNE $ae4f ; cursor on left - activate menu ,ae33 c5 b4 CMP $b4 ; menu title right edge vs cursor position ,ae35 f0 02 BEQ $ae39 ; cursor on edge - no hit ,ae37 b0 16 BCS $ae4f ; cursor on left - activate menu ,ae39 85 8c STA $8c ; next menu starting position ,ae3b a5 c3 LDA $c3 ,ae3d 85 8b STA $8b ; msb ,ae3f a0 00 LDY #$00 ,ae41 b1 94 LDA ($94),Y ; get next menu ,ae43 aa TAX ,ae44 c8 INY ,ae45 b1 94 LDA ($94),Y ,ae47 f0 54 BEQ $ae9d ; no hit, stay in loop for cursor movement ,ae49 86 94 STX $94 ; save next menu address ,ae4b 85 95 STA $95 ,ae4d d0 d0 BNE $ae1f ; loop through menus ; -- activate menu ,ae4f 8a TXA ,ae50 85 96 STA $96 ; menu title width ,ae52 4a LSR ,ae53 4a LSR ,ae54 4a LSR ,ae55 85 8e STA $8e ; menu title width in chars ,ae57 ae 12 c0 LDX $c012 ; active item color ,ae5a 20 79 ac JSR $ac79 ; highlight menu title ,ae5d 20 4b af JSR $af4b ; save area under drop-down menu ,ae60 20 2f ad JSR $ad2f ; handle cursor over drop-down menu ,ae63 20 51 af JSR $af51 ; restore area under drop-down menu ,ae66 a9 00 LDA #$00 ,ae68 85 9f STA $9f ; line number 0 for remove highlight ,ae6a a0 06 LDY #$06 ,ae6c b1 94 LDA ($94),Y ,ae6e 85 96 STA $96 ; window title height ,ae70 ae 11 c0 LDX $c011 ; inactive item color ,ae73 20 79 ac JSR $ac79 ; remove menu title highlight ,ae76 ad 0f c0 LDA $c00f ; selected item index ,ae79 f0 22 BEQ $ae9d ; no item selected ,ae7b a0 02 LDY #$02 ,ae7d b1 94 LDA ($94),Y ; first menu item ,ae7f 85 9b STA $9b ,ae81 c8 INY ,ae82 b1 94 LDA ($94),Y ,ae84 85 9c STA $9c ,ae86 f0 15 BEQ $ae9d ; menu item mysteriously disappeared ,ae88 ce 0f c0 DEC $c00f ; decrement item index ,ae8b f0 23 BEQ $aeb0 ; this item selected ,ae8d a0 00 LDY #$00 ; get next menu item ,ae8f b1 9b LDA ($9b),Y ,ae91 aa TAX ,ae92 c8 INY ,ae93 b1 9b LDA ($9b),Y ,ae95 86 9b STX $9b ,ae97 85 9c STA $9c ,ae99 f0 02 BEQ $ae9d ,ae9b d0 eb BNE $ae88 ; menu item loop ,ae9d ae 24 c0 LDX $c024 ; restore top window address ,aea0 ac 25 c0 LDY $c025 ,aea3 86 94 STX $94 ,aea5 84 95 STY $95 ,aea7 ad c8 03 LDA $03c8 ,aeaa d0 03 BNE $aeaf ,aeac 4c e8 ad JMP $ade8 ; loop until button released ,aeaf 60 RTS ; button released >aeb0 ; -- handle menu item clicked ] descr: ] Handle menu item clicked ] input: ] $9b,$9c = menu item address ] uses: ] $a3,$a4 = menu text address ] $a3,$a4 = menu item procedure address ,aeb0 a0 06 LDY #$06 ,aeb2 b1 9b LDA ($9b),Y ; menu item flags ,aeb4 aa TAX ,aeb5 29 01 AND #$01 ,aeb7 f0 e4 BEQ $ae9d ; not ENABLED, ignore click ,aeb9 8a TXA ,aeba 29 20 AND #$20 ; test TOGGLE ,aebc f0 26 BEQ $aee4 ; not enabled ,aebe 8a TXA ,aebf 49 02 EOR #$02 ; toggle STATUS flag ,aec1 91 9b STA ($9b),Y ,aec3 8a TXA ,aec4 29 02 AND #$02 ; get reversed STATUS flag ,aec6 f0 04 BEQ $aecc ,aec8 a0 0a LDY #$0a ; OFF marker (typically $7b) offset ,aeca d0 02 BNE $aece ,aecc a0 09 LDY #$09 ; ON marker (typically $1f) offset ,aece b1 9b LDA ($9b),Y ; get marker character ,aed0 aa TAX ,aed1 a0 02 LDY #$02 ; get item text pointer ,aed3 b1 9b LDA ($9b),Y ,aed5 85 a3 STA $a3 ,aed7 c8 INY ,aed8 b1 9b LDA ($9b),Y ,aeda 85 a4 STA $a4 ,aedc a0 08 LDY #$08 ; get marker offset ,aede b1 9b LDA ($9b),Y ,aee0 a8 TAY ,aee1 8a TXA ,aee2 91 a3 STA ($a3),Y ; put marker into item text ,aee4 a0 04 LDY #$04 ,aee6 b1 9b LDA ($9b),Y ,aee8 85 a3 STA $a3 ; get item procedure - low byte ,aeea c8 INY ,aeeb b1 9b LDA ($9b),Y ,aeed 85 a4 STA $a4 ; - high byte ,aeef f0 ac BEQ $ae9d ; no item procedure ,aef1 a0 06 LDY #$06 ,aef3 b1 9b LDA ($9b),Y ,aef5 aa TAX ; x = item flags ,aef6 c8 INY ,aef7 b1 9b LDA ($9b),Y ,aef9 a8 TAY ; y = item user value ,aefa ad 24 c0 LDA $c024 ; select top window ,aefd 85 94 STA $94 ,aeff ad 25 c0 LDA $c025 ,af02 85 95 STA $95 ,af04 4c 17 de JMP $de17 ; switch to ROM 2 and call menu item procedure >af07 ; -- prepare for saving/restoring area under drop-down menu ] descr: ] Prepare for saving/restoring area under drop-down menu ] input: ] $8b,$8c = menu position x ] calls: ] $815f = set drawing position ] output: ] $a7,$a8 = scratch area pointer ] $a3 = (menu height + 7) / 8 + 1 ] $a4 = (menu width + 7) & ~7 ] $c014 = second scratch area page ] $fd-$ff = drawing pointer address ,af07 a5 8b LDA $8b ; menu position x - bit 8 ,af09 a6 8c LDX $8c ; menu position x ,af0b a0 08 LDY #$08 ,af0d 20 5f 81 JSR $815f ; set drawing position ,af10 a0 07 LDY #$07 ,af12 b1 94 LDA ($94),Y ; menu height ,af14 85 a3 STA $a3 ,af16 4a LSR ,af17 4a LSR ,af18 4a LSR ,af19 aa TAX ,af1a a5 a3 LDA $a3 ,af1c 29 07 AND #$07 ,af1e f0 01 BEQ $af21 ,af20 e8 INX ,af21 e8 INX ,af22 86 a3 STX $a3 ; menu height in char-box units + 1 ,af24 c8 INY ,af25 b1 94 LDA ($94),Y ; menu width ,af27 85 a4 STA $a4 ,af29 29 07 AND #$07 ,af2b f0 09 BEQ $af36 ,af2d a5 a4 LDA $a4 ,af2f 29 f8 AND #$f8 ,af31 18 CLC ,af32 69 08 ADC #$08 ,af34 85 a4 STA $a4 ; menu width aligned to char box unit ,af36 a9 20 LDA #$20 ,af38 a2 00 LDX #$00 ,af3a a0 26 LDY #$26 ; scratch area in screen back buffer ,af3c c5 92 CMP $92 ,af3e d0 02 BNE $af42 ,af40 a0 46 LDY #$46 ; scratch area in screen back buffer ,af42 86 a7 STX $a7 ,af44 84 a8 STY $a8 ,af46 88 DEY ,af47 8c 14 c0 STY $c014 ; second scratch area ,af4a 60 RTS >af4b ; -- save area under drop-down menu ] descr: ] Save area under drop-down menu ] calls: ] $af07 = prepare for saving/restoring ] $b03c = save area ,af4b 20 07 af JSR $af07 ; prepare for saving/restoring ,af4e 4c 3c b0 JMP $b03c ; save area >af51 ; -- restore area under drop-down menu ] descr: ] Restore area under drop-down menu ] Clear second scratch area ] calls: ] $af07 = prepare for saving/restoring ] $b06b = restore area ,af51 20 07 af JSR $af07 ; prepare for saving/restoring ,af54 20 6b b0 JSR $b06b ; restore area ,af57 a9 00 LDA #$00 ; clear second scratch area ,af59 ac 14 c0 LDY $c014 ,af5c 85 a3 STA $a3 ,af5e 84 a4 STY $a4 ,af60 a2 19 LDX #$19 ,af62 a8 TAY ,af63 91 a3 STA ($a3),Y ,af65 c8 INY ,af66 ca DEX ,af67 d0 fa BNE $af63 ,af69 60 RTS >af6a ; -- gray-out text ] descr: ] Gray-out menu item text ] inputs: ] $c008,$c009 = drawing address ] $96 = width in pixels ] uses: ] $a3,$a4 ,af6a ad 08 c0 LDA $c008 ; drawing address ,af6d ac 09 c0 LDY $c009 ,af70 29 f8 AND #$f8 ; move to beginning of char-box ,af72 85 a3 STA $a3 ,af74 84 a4 STY $a4 ,af76 a5 96 LDA $96 ; width ,af78 29 f8 AND #$f8 ; align to 8 bytes ,af7a 4a LSR ,af7b 4a LSR ,af7c aa TAX ; x=width/4 ,af7d a0 00 LDY #$00 ,af7f b1 a3 LDA ($a3),Y ,af81 09 11 ORA #$11 ; pattern 1 ,af83 91 a3 STA ($a3),Y ,af85 c8 INY ,af86 b1 a3 LDA ($a3),Y ,af88 09 22 ORA #$22 ; pattern 2 ,af8a 91 a3 STA ($a3),Y ,af8c c8 INY ,af8d b1 a3 LDA ($a3),Y ,af8f 09 44 ORA #$44 ; pattern 3 ,af91 91 a3 STA ($a3),Y ,af93 c8 INY ,af94 b1 a3 LDA ($a3),Y ,af96 09 88 ORA #$88 ; pattern 4 ,af98 91 a3 STA ($a3),Y ,af9a c8 INY ,af9b ca DEX ; decrement counter ,af9c d0 e1 BNE $af7f ,af9e 60 RTS # call #3d - SET MENU ITEM PROCEDURE >af9f ; -- set menu item procedure ] descr: ] Set menu item procedure ] Set/clear menu item ENABLED flag ] inputs: ] x,y = item procedure address ] $fa = drop-down menu number ] $fc = item number ] $03ce,$03cf = menu start address ] uses: ] $a5,$a6 = item procedure address ] $a3,$a4 = menu pointer ,af9f 86 a5 STX $a5 ,afa1 84 a6 STY $a6 ,afa3 ae ce 03 LDX $03ce ; menu start address ,afa6 ac cf 03 LDY $03cf ,afa9 86 a3 STX $a3 ; menu pointer ,afab 84 a4 STY $a4 ,afad a6 fa LDX $fa ; get drop-down menu number ,afaf f0 54 BEQ $b005 ; invalid menu number ,afb1 c6 fa DEC $fa ,afb3 f0 10 BEQ $afc5 ; this menu ,afb5 a0 00 LDY #$00 ; get next drop-down menu ,afb7 b1 a3 LDA ($a3),Y ,afb9 aa TAX ,afba c8 INY ,afbb b1 a3 LDA ($a3),Y ,afbd 86 a3 STX $a3 ,afbf 85 a4 STA $a4 ,afc1 f0 42 BEQ $b005 ; no more menus ,afc3 d0 ec BNE $afb1 ; loop through drop-down menus ,afc5 a0 02 LDY #$02 ; get first item ,afc7 b1 a3 LDA ($a3),Y ,afc9 aa TAX ,afca c8 INY ,afcb b1 a3 LDA ($a3),Y ,afcd 86 a3 STX $a3 ; save item address ,afcf 85 a4 STA $a4 ,afd1 f0 32 BEQ $b005 ; no items ,afd3 a5 fc LDA $fc ; get item number ,afd5 f0 2e BEQ $b005 ; invalid item number ,afd7 c6 fc DEC $fc ,afd9 f0 10 BEQ $afeb ; this item ,afdb a0 00 LDY #$00 ,afdd b1 a3 LDA ($a3),Y ; get next item ,afdf aa TAX ,afe0 c8 INY ,afe1 b1 a3 LDA ($a3),Y ,afe3 86 a3 STX $a3 ,afe5 85 a4 STA $a4 ,afe7 f0 1c BEQ $b005 ; no more items ,afe9 d0 ec BNE $afd7 ; loop through menu items ,afeb a0 04 LDY #$04 ,afed a5 a5 LDA $a5 ,afef 91 a3 STA ($a3),Y ; set item procedure address ,aff1 c8 INY ,aff2 a5 a6 LDA $a6 ,aff4 91 a3 STA ($a3),Y ,aff6 c8 INY ,aff7 b1 a3 LDA ($a3),Y ,aff9 a6 a6 LDX $a6 ; procedure not null? ,affb f0 04 BEQ $b001 ,affd 09 01 ORA #$01 ; enable menu item ,afff d0 02 BNE $b003 ,b001 29 fe AND #$fe ; disable menu item ,b003 91 a3 STA ($a3),Y ,b005 60 RTS >b006 ; -- install default menu ] descr: ] Copy ROM $a863-$a97a to RAM $c060 ] Set menu address to $c060 and draw menu ] Display desktop version text in both screen buffers ] calls: ] $ac00 = set menu address and draw menu ] $b026 = display desktop version text ,b006 a0 00 LDY #$00 ; copy default menu data from $a863 to $c060 ,b008 b9 63 a8 LDA $a863,Y ,b00b 99 60 c0 STA $c060,Y ,b00e c8 INY ,b00f d0 f7 BNE $b008 ,b011 a0 17 LDY #$17 ,b013 b9 62 a9 LDA $a962,Y ,b016 99 5f c1 STA $c15f,Y ,b019 88 DEY ,b01a d0 f7 BNE $b013 ,b01c a2 60 LDX #$60 ,b01e a0 c0 LDY #$c0 ,b020 20 00 ac JSR $ac00 ; set menu address and draw menu ,b023 20 26 b0 JSR $b026 ; display desktop version on both screen buffers # call #4f - DISPLAY DESKTOP VERSION TEXT >b026 ; -- display desktop version text ] descr: ] Display "DESKTOP V1.0" text on menu bar ] Switch output screen buffer ] note: ] Called twice to display text in both screen buffers ] calls: ] $815f = set drawing position ] $840a = display text ] $8e2e = switch output screen buffer ,b026 a9 01 LDA #$01 ; set drawing position to x=$101, y=1 ,b028 aa TAX ,b029 a8 TAY ,b02a 20 5f 81 JSR $815f ,b02d a9 01 LDA #$01 ,b02f a2 56 LDX #$56 ,b031 a0 a8 LDY #$a8 ,b033 20 0a 84 JSR $840a ; display text "DESKTOP V1.0" ,b036 4c 2e 8e JMP $8e2e ; switch output screen buffer # call #4b - SAVE SCREEN AREA >b039 ; -- save area ] descr: ] Save screen area ] note: ] Used for saving area under message box ] inputs: ] x = position x ] y = position y ] $a3 = height ] $a4 = width ] calls: ] $b099 = prepare pointers and counters for saving/restoring screen area ,b039 20 99 b0 JSR $b099 ; prepare pointers and counters >b03c ; -- save area ] descr: ] Save screen area ] note: ] Used for saving area under drop-down menu ] inputs: ] $fe,$ff = screen area pointer ] $a7,$a8 = backup buffer pointer ] $a3 = height/8 ] $a4 = width in pixels (aligned to 8) ,b03c a0 00 LDY #$00 ,b03e a6 a4 LDX $a4 ,b040 b1 fe LDA ($fe),Y ; copy byte from screen to backup buffer ,b042 91 a7 STA ($a7),Y ,b044 c8 INY ,b045 ca DEX ,b046 d0 f8 BNE $b040 ; byte loop ,b048 20 50 b0 JSR $b050 ; move to next char-line ,b04b c6 a3 DEC $a3 ; decrement char-line counter ,b04d d0 ed BNE $b03c ; char-line loop ,b04f 60 RTS ; -- move to next char-line ,b050 18 CLC ,b051 98 TYA ,b052 65 a7 ADC $a7 ; move backup buffer pointer ,b054 85 a7 STA $a7 ,b056 90 02 BCC $b05a ,b058 e6 a8 INC $a8 ,b05a 18 CLC ,b05b a5 fe LDA $fe ; move screen pointer ,b05d 69 40 ADC #$40 ,b05f 85 fe STA $fe ,b061 a5 ff LDA $ff ,b063 69 01 ADC #$01 ,b065 85 ff STA $ff ,b067 60 RTS # call #4c - RESTORE SCREEN AREA >b068 ; -- restore area ] descr: ] Restore screen area ] Clear backup buffer ] note: ] Used for restoring area under message box ] inputs: ] x = position x ] y = position y ] $a3 = height ] $a4 = width ] calls: ] $b099 = prepare pointers and counters for saving/restoring screen area ,b068 20 99 b0 JSR $b099 ; prepare pointers and counters >b06b ; -- restore area ] descr: ] Restore screen area ] Clear backup buffer ] note: ] Used for restoring area under drop-down menu ] inputs: ] $fe,$ff = screen area pointer ] $a7,$a8 = backup buffer pointer ] $a3 = height/8 ] $a4 = width in pixels (aligned to 8) ] calls: ] $b099 = prepare pointers and counters for saving/restoring screen area ,b06b a0 00 LDY #$00 ,b06d a6 a4 LDX $a4 ,b06f b1 a7 LDA ($a7),Y ; copy byte from backup buffer to screen ,b071 91 fe STA ($fe),Y ,b073 a9 00 LDA #$00 ; clear byte in backup buffer ,b075 91 a7 STA ($a7),Y ,b077 c8 INY ,b078 ca DEX ,b079 d0 f4 BNE $b06f ; byte loop ,b07b 20 50 b0 JSR $b050 ; move to next char-line ,b07e c6 a3 DEC $a3 ; decrement char-line counter ,b080 d0 e9 BNE $b06b ; char-line loop ,b082 60 RTS >b083 ; -- clear save/restore buffer ] descr: ] Clear backup buffer ] inputs: ] x = position x ] y = position y ] $a3 = height ] $a4 = width ] calls: ] $b099 = prepare pointers and counters for saving/restoring screen area ,b083 20 99 b0 JSR $b099 ; prepare pointers and counters >b086 ; -- clear save/restore buffer ] descr: ] Clear backup buffer ] inputs: ] $a7,$a8 = backup buffer pointer ] $a3 = height/8 ] $a4 = width in pixels (aligned to 8) ,b086 a0 00 LDY #$00 ,b088 98 TYA ,b089 a6 a4 LDX $a4 ,b08b 91 a7 STA ($a7),Y ; clear byte in backup buffer ,b08d c8 INY ,b08e ca DEX ,b08f d0 fa BNE $b08b ; byte loop ,b091 20 50 b0 JSR $b050 ; move to next char-line ,b094 c6 a3 DEC $a3 ; decrement char-line counter ,b096 d0 ee BNE $b086 ; char-line loop ,b098 60 RTS >b099 ; -- prepare screen area save/restore ] descr: ] Prepare pointers and counters for saving/restoring screen area ] inputs: ] x = position x ] y = position y ] $a3 = height ] $a4 = width ] calls: ] $815d = set drawing position ] output: ] $fe,$ff = screen start address ] $a7,$a8 = backup buffer address ] $a3 = height in char-box units ] $a4 = width aligned to char-box unit ,b099 20 5d 81 JSR $815d ; set drawing position to x,y ,b09c 38 SEC ,b09d a5 fe LDA $fe ; start line number within char-box ,b09f 29 07 AND #$07 ,b0a1 65 a3 ADC $a3 ; add height ,b0a3 4a LSR ,b0a4 4a LSR ,b0a5 4a LSR ,b0a6 aa TAX ,b0a7 29 07 AND #$07 ,b0a9 f0 01 BEQ $b0ac ,b0ab e8 INX ,b0ac 86 a3 STX $a3 ; save height in char-high units ,b0ae e6 a4 INC $a4 ; increment width ,b0b0 a5 a4 LDA $a4 ; align up to 8 ,b0b2 29 07 AND #$07 ,b0b4 f0 09 BEQ $b0bf ,b0b6 a5 a4 LDA $a4 ,b0b8 29 f8 AND #$f8 ,b0ba 18 CLC ,b0bb 69 08 ADC #$08 ,b0bd 85 a4 STA $a4 ,b0bf a5 fe LDA $fe ; align screen pointer down to char-box ,b0c1 29 f8 AND #$f8 ,b0c3 85 fe STA $fe ,b0c5 a9 20 LDA #$20 ,b0c7 a2 00 LDX #$00 ,b0c9 a0 30 LDY #$30 ; backup buffer for $4000 at $3000 ,b0cb c5 92 CMP $92 ; screen buffer <> $2000 ? ,b0cd d0 02 BNE $b0d1 ; yes ,b0cf a0 50 LDY #$50 ; backup buffer for $2000 at $5000 ,b0d1 86 a7 STX $a7 ; save backup buffer address ,b0d3 84 a8 STY $a8 ,b0d5 60 RTS # call #49 - SHOW SMALL MESSAGE BOX ("REQUESTER") >b0d6 ; -- show small message box ] descr: ] Show large message box ] note: ] Doesn't return until message box is closed ] input: ] x,y = message box data address ] uses: ] $c13f,$c140 = message box position ] $c14f,$c150 = message box size ] $c004,$c005,$c006 ] $c00f,$c010 = fake gadget position (0,0), button position ] $c136,$c137 = left button position ] $c138 = left button width ] $c146,$c147 = right button position ] $c148 = right button width ] $c13a,$c14a ] $94,$95 = message box data address ] $8e,$8f = button text address ] calls: ] $b370 = save temporary zero-page registers in stack area ] $b33a = get message box placement ] $b039 = save screen area ] $b12f = get message box placement ] $8237 = background filled box ] $820b = rectangle ] $b145 = get message box internal area ] $8233 = foreground filled box ] $99b7 = draw list of text ] $9235 = draw image relative to window ] $b358 = set default OK text address ] $95bc = calculate text width ] $b364 = set default CANCEL text address ] $b34b = prepare for clear button area ] $914a = draw gadget ] $83a5 = invert box ] $b2be = draw button text ] $b2ce = draw centered button text ] $de65 = update clock ] $97ed = get relative pointer position within window ] $9117 = select gadget ] $94b1 = gadget hit test ] $97db = invert gadget area ] $b068 = restore screen area ] $b083 = clear backup buffer ] $b37f = restore zero-page registers ,b0d6 a9 50 LDA #$50 ,b0d8 8d 3f c1 STA $c13f ; message box position y ,b0db a9 41 LDA #$41 ,b0dd 8d 40 c1 STA $c140 ; position y ,b0e0 a9 a0 LDA #$a0 ,b0e2 8d 4f c1 STA $c14f ; width ,b0e5 a9 46 LDA #$46 ,b0e7 8d 50 c1 STA $c150 ; height ,b0ea d0 14 BNE $b100 # call #4a - SHOW LARGE MESSAGE BOX ("REQUESTER") >b0ec ; -- show large message box ] descr: ] Show large message box ] note: ] Doesn't return until message box is closed ] input: ] x,y = message box data address ] uses: ] $c13f,$c140 = message box position ] $c14f,$c150 = message box size ] $c004,$c005,$c006 ] $c00f,$c010 = fake gadget position (0,0), button position ] $c136,$c137 = left button position ] $c138 = left button width ] $c146,$c147 = right button position ] $c148 = right button width ] $c13a,$c14a ] $94,$95 = message box data address ] $8e,$8f = button text address ] calls: ] $b370 = save temporary zero-page registers in stack area ] $b33a = get message box placement ] $b039 = save screen area ] $b12f = get message box placement ] $8237 = background filled box ] $820b = rectangle ] $b145 = get message box internal area ] $8233 = foreground filled box ] $99b7 = draw list of text ] $9235 = draw image relative to window ] $b358 = set default OK text address ] $95bc = calculate text width ] $b364 = set default CANCEL text address ] $b34b = prepare for clear button area ] $914a = draw gadget ] $83a5 = invert box ] $b2be = draw button text ] $b2ce = draw centered button text ] $de65 = update clock ] $97ed = get relative pointer position within window ] $9117 = select gadget ] $94b1 = gadget hit test ] $97db = invert gadget area ] $b068 = restore screen area ] $b083 = clear backup buffer ] $b37f = restore zero-page registers ,b0ec a9 3c LDA #$3c ,b0ee 8d 3f c1 STA $c13f ; message box position x ,b0f1 a9 32 LDA #$32 ,b0f3 8d 40 c1 STA $c140 ; position y ,b0f6 a9 c8 LDA #$c8 ,b0f8 8d 4f c1 STA $c14f ; width ,b0fb a9 64 LDA #$64 ,b0fd 8d 50 c1 STA $c150 ; height ,b100 8e 3a c1 STX $c13a ; message box data address ,b103 8c 4a c1 STY $c14a ,b106 20 70 b3 JSR $b370 ; save temporary zero-page registers in stack area ,b109 ae 3a c1 LDX $c13a ,b10c ac 4a c1 LDY $c14a ,b10f 86 94 STX $94 ; save message box data address ,b111 84 95 STY $95 ,b113 20 3a b3 JSR $b33a ; get message box position and size ,b116 20 39 b0 JSR $b039 ; save area under message box ,b119 a9 00 LDA #$00 ; clear message box data ,b11b 8d 06 c0 STA $c006 ; button width ,b11e 8d 04 c0 STA $c004 ; message box flags ,b121 8d 3a c1 STA $c13a ,b124 8d 4a c1 STA $c14a ,b127 8d 0f c0 STA $c00f ; "gadget position" for drawing texts ,b12a 8d 10 c0 STA $c010 ,b12d f0 2c BEQ $b15b >b12f ; -- get message box placement ] descr: ] Get message box placement ] input: ] $c13f,$c140 = message box position ] $c14f,$c150 = message box size ] calls: ] $815d = set drawing position ] output: ] $c000,$c001 = message box position ] x,y = message box size ] $fd-$ff = drawing position address ,b12f ae 3f c1 LDX $c13f ; message box position ,b132 ac 40 c1 LDY $c140 ,b135 8e 00 c0 STX $c000 ; set as current window position ,b138 8c 01 c0 STY $c001 ,b13b 20 5d 81 JSR $815d ; set drawing position ,b13e ae 4f c1 LDX $c14f ; get message box size ,b141 ac 50 c1 LDY $c150 ,b144 60 RTS >b145 ; -- get message box internal area ] descr: ] Get message box internal area ] input: ] $c000,$c001 = message box position ] $c14f,$c150 = message box size ] calls: ] $91f2 = set drawing position relative to window ] output: ] $fd-$ff = drawing position address (msgbox position + (2,2)) ] x,y = message box size - (4,4) ,b145 a2 02 LDX #$02 ; set drawing position relative to message box ,b147 a0 02 LDY #$02 ; [(left,top)+(2,2)] ,b149 20 f2 91 JSR $91f2 ,b14c 38 SEC ,b14d ad 4f c1 LDA $c14f ; get message box size [(width,height)-(4,4)] ,b150 e9 04 SBC #$04 ,b152 aa TAX ,b153 38 SEC ,b154 ad 50 c1 LDA $c150 ,b157 e9 04 SBC #$04 ,b159 a8 TAY ,b15a 60 RTS ; -- show message box continued ,b15b 20 2f b1 JSR $b12f ; get message box position and size ,b15e 20 37 82 JSR $8237 ; background fill ,b161 20 2f b1 JSR $b12f ; get message box position and size ,b164 20 0b 82 JSR $820b ; draw border ,b167 20 2f b1 JSR $b12f ; get message box position and size ,b16a 20 45 b1 JSR $b145 ; get internal area ,b16d 20 33 82 JSR $8233 ; foreground filled box ,b170 a0 00 LDY #$00 ; address of list of texts ,b172 b1 94 LDA ($94),Y ,b174 aa TAX ,b175 c8 INY ,b176 b1 94 LDA ($94),Y ,b178 f0 04 BEQ $b17e ,b17a a8 TAY ,b17b 20 b7 99 JSR $99b7 ; draw message box texts ,b17e a0 06 LDY #$06 ; address of message box image ,b180 b1 94 LDA ($94),Y ,b182 aa TAX ,b183 c8 INY ,b184 b1 94 LDA ($94),Y ,b186 f0 04 BEQ $b18c ,b188 a8 TAY ,b189 20 35 92 JSR $9235 ; draw message box image ,b18c a0 03 LDY #$03 ; left button text ,b18e b1 94 LDA ($94),Y ,b190 f0 23 BEQ $b1b5 ; no left button ,b192 c9 ff CMP #$ff ; default text ,b194 d0 03 BNE $b199 ,b196 20 58 b3 JSR $b358 ; set default text address (OK) ,b199 85 8f STA $8f ,b19b a0 02 LDY #$02 ; text address lo byte ,b19d b1 94 LDA ($94),Y ,b19f 85 8e STA $8e ,b1a1 a9 81 LDA #$81 ; spacing = 1, bold ,b1a3 a4 8f LDY $8f ,b1a5 a6 8e LDX $8e ,b1a7 20 bc 95 JSR $95bc ; calculate text width ,b1aa 8e 04 c0 STX $c004 ; save text width ,b1ad ad 06 c0 LDA $c006 ; left button present flag ,b1b0 09 01 ORA #$01 ,b1b2 8d 06 c0 STA $c006 ,b1b5 a0 05 LDY #$05 ; right button text ,b1b7 b1 94 LDA ($94),Y ,b1b9 f0 34 BEQ $b1ef ; no right button ,b1bb c9 ff CMP #$ff ; default text ,b1bd d0 03 BNE $b1c2 ,b1bf 20 64 b3 JSR $b364 ; set default text address (CANCEL) ,b1c2 85 8f STA $8f ,b1c4 a0 04 LDY #$04 ; text address lo byte ,b1c6 b1 94 LDA ($94),Y ,b1c8 85 8e STA $8e ,b1ca a9 81 LDA #$81 ; spacing = 1, bold ,b1cc a4 8f LDY $8f ,b1ce a6 8e LDX $8e ,b1d0 20 bc 95 JSR $95bc ; calculate text width ,b1d3 ad 06 c0 LDA $c006 ; right button present flag ,b1d6 09 02 ORA #$02 ,b1d8 8d 06 c0 STA $c006 ,b1db ec 04 c0 CPX $c004 ,b1de 90 0c BCC $b1ec ,b1e0 ad 04 c0 LDA $c004 ; right button text wider: ,b1e3 8d 3a c1 STA $c13a ; $c004=right, $c13a=left, $c14a=0 ,b1e6 8e 04 c0 STX $c004 ,b1e9 18 CLC ,b1ea 90 03 BCC $b1ef ; left button text wider: ,b1ec 8e 4a c1 STX $c14a ; $c004=left, $c14a=right, $c13a=0 ,b1ef 18 CLC ,b1f0 ad 04 c0 LDA $c004 ; sigh... ,b1f3 8d 05 c0 STA $c005 ; wider text width ,b1f6 69 0a ADC #$0a ,b1f8 8d 04 c0 STA $c004 ; text width+10 ,b1fb 18 CLC ,b1fc ad 05 c0 LDA $c005 ,b1ff 69 06 ADC #$06 ; text width+6 ,b201 8d 38 c1 STA $c138 ; left button width ,b204 8d 48 c1 STA $c148 ; right button width ,b207 8d 05 c0 STA $c005 ,b20a ad 06 c0 LDA $c006 ,b20d 29 01 AND #$01 ; left button present ,b20f f0 50 BEQ $b261 ; -- left button ,b211 a9 0c LDA #$0c ,b213 8d 36 c1 STA $c136 ; position x = 12 ,b216 38 SEC ,b217 ad 50 c1 LDA $c150 ,b21a e9 17 SBC #$17 ,b21c 8d 37 c1 STA $c137 ; position y = message box height-23 ,b21f a2 09 LDX #$09 ; x = 9 ,b221 38 SEC ,b222 ad 50 c1 LDA $c150 ,b225 e9 1a SBC #$1a ; y = message box height - 26 ,b227 a8 TAY ,b228 20 4b b3 JSR $b34b ; set drawing postion and get size ,b22b 20 37 82 JSR $8237 ; clear button area ,b22e a2 34 LDX #$34 ,b230 a0 c1 LDY #$c1 ,b232 20 4a 91 JSR $914a ; draw left button using gadget drawing procedure ,b235 a2 09 LDX #$09 ,b237 38 SEC ,b238 ad 50 c1 LDA $c150 ,b23b e9 1a SBC #$1a ,b23d a8 TAY ,b23e 20 4b b3 JSR $b34b ; set drawing position and get size ,b241 20 a5 83 JSR $83a5 ; invert button area ,b244 a0 02 LDY #$02 ; button text address ,b246 b1 94 LDA ($94),Y ,b248 85 8e STA $8e ,b24a c8 INY ,b24b b1 94 LDA ($94),Y ,b24d f0 12 BEQ $b261 ,b24f 85 8f STA $8f ,b251 ad 3a c1 LDA $c13a ; text width if text is to be centered ,b254 d0 06 BNE $b25c ,b256 20 be b2 JSR $b2be ; draw text ,b259 18 CLC ,b25a 90 05 BCC $b261 ,b25c 85 8d STA $8d ,b25e 20 ce b2 JSR $b2ce ; draw centered text ,b261 ad 06 c0 LDA $c006 ,b264 29 02 AND #$02 ,b266 f0 71 BEQ $b2d9 ; -- right button ,b268 38 SEC ,b269 ad 4f c1 LDA $c14f ; message box width ,b26c e9 0c SBC #$0c ,b26e ed 04 c0 SBC $c004 ,b271 aa TAX ; x = message box width - 12 - (button width+4) ,b272 69 03 ADC #$03 ,b274 8d 46 c1 STA $c146 ; position x ,b277 38 SEC ,b278 ad 50 c1 LDA $c150 ; message box height ,b27b e9 1b SBC #$1b ,b27d a8 TAY ; y = message box height - 27 (?) ,b27e 69 03 ADC #$03 ,b280 8d 47 c1 STA $c147 ; position y ,b283 86 8e STX $8e ,b285 84 8f STY $8f ,b287 20 4b b3 JSR $b34b ; set drawing position and get size ,b28a 20 37 82 JSR $8237 ; clear button area ,b28d a2 44 LDX #$44 ,b28f a0 c1 LDY #$c1 ,b291 20 4a 91 JSR $914a ; draw right button using gadget drawing procedure ,b294 a6 8e LDX $8e ,b296 a4 8f LDY $8f ,b298 20 4b b3 JSR $b34b ; set drawing position and get size ,b29b 20 a5 83 JSR $83a5 ; invert button area ,b29e a0 04 LDY #$04 ; button text address ,b2a0 b1 94 LDA ($94),Y ,b2a2 85 8e STA $8e ,b2a4 c8 INY ,b2a5 b1 94 LDA ($94),Y ,b2a7 f0 30 BEQ $b2d9 ,b2a9 85 8f STA $8f ,b2ab ad 4a c1 LDA $c14a ; text width if text to be centered ,b2ae d0 06 BNE $b2b6 ,b2b0 20 be b2 JSR $b2be ; draw text ,b2b3 18 CLC ,b2b4 90 23 BCC $b2d9 ,b2b6 85 8d STA $8d ,b2b8 20 ce b2 JSR $b2ce ; draw centered text ,b2bb 18 CLC ,b2bc 90 1b BCC $b2d9 >b2be ; -- draw button text ] descr: ] Draw button text ] input: ] $8e,$8f = button text address ] calls: ] $91e6 = set drawing position relative to gadget ] $840a = draw text ,b2be a2 04 LDX #$04 ,b2c0 a0 02 LDY #$02 ,b2c2 20 e6 91 JSR $91e6 ; set drawing position relative to button edge ,b2c5 a6 8e LDX $8e ; button text address ,b2c7 a4 8f LDY $8f ,b2c9 a9 81 LDA #$81 ; spacing=1, bold ,b2cb 4c 0a 84 JMP $840a ; draw button text >b2ce ; -- draw centered button text ] descr: ] Draw button text ] input: ] $c004 = button width ] $8d = text width ] $8e,$8f = button text address ] calls: ] $91e6 = set drawing position relative to gadget ] $840a = draw text ,b2ce 38 SEC ,b2cf ad 04 c0 LDA $c004 ,b2d2 e5 8d SBC $8d ,b2d4 4a LSR ,b2d5 aa TAX ; x=(button width-text width)/2 ,b2d6 4c c0 b2 JMP $b2c0 ; draw button text ; -- show message box continued ,b2d9 20 65 de JSR $de65 ; update clock ,b2dc ad c8 03 LDA $03c8 ; wait for button press ,b2df d0 f8 BNE $b2d9 ,b2e1 20 ed 97 JSR $97ed ; get relative pointer position ,b2e4 a0 03 LDY #$03 ; left button present? ,b2e6 b1 94 LDA ($94),Y ,b2e8 f0 0c BEQ $b2f6 ,b2ea a2 34 LDX #$34 ; left button gadget address ,b2ec a0 c1 LDY #$c1 ,b2ee 20 17 91 JSR $9117 ; select gadget ,b2f1 20 b1 94 JSR $94b1 ; test button clicked ,b2f4 b0 14 BCS $b30a ,b2f6 a0 05 LDY #$05 ; right button present? ,b2f8 b1 94 LDA ($94),Y ,b2fa f0 dd BEQ $b2d9 ,b2fc a2 44 LDX #$44 ; right button gadget address ,b2fe a0 c1 LDY #$c1 ,b300 f0 d7 BEQ $b2d9 ,b302 20 17 91 JSR $9117 ; select gadget ,b305 20 b1 94 JSR $94b1 ; test button clicked ,b308 90 cf BCC $b2d9 ,b30a 20 db 97 JSR $97db ; reverse button area ,b30d ad c8 03 LDA $03c8 ; wait for button release ,b310 f0 fb BEQ $b30d ,b312 20 db 97 JSR $97db ; reverse button area ,b315 20 ed 97 JSR $97ed ; get relative pointer position ,b318 20 b1 94 JSR $94b1 ; test pointer in button area ,b31b 90 bc BCC $b2d9 ; pointer left button area ,b31d a0 0f LDY #$0f ,b31f b1 9b LDA ($9b),Y ,b321 48 PHA ,b322 85 8f STA $8f ; get usr button data - $00 = left, $ff = right ,b324 20 3a b3 JSR $b33a ; get message box position and size ,b327 20 68 b0 JSR $b068 ; restore area under message box ,b32a 20 3a b3 JSR $b33a ,b32d 20 83 b0 JSR $b083 ; clear backup buffer ($b068 already did this) ,b330 20 7f b3 JSR $b37f ; restore zero-page registers and top window data ,b333 a9 00 LDA #$00 ; clear keyboard buffer ,b335 85 c6 STA $c6 ,b337 68 PLA ,b338 aa TAX ,b339 60 RTS >b33a ; -- get message box position and size ] descr: ] Get message box placement ] input: ] $c13f,$c140 = message box position ] $c14f,$c150 = message box size ] output: ] x,y = message box position ] $a3,$a4 = message box size ,b33a ae 4f c1 LDX $c14f ; get message box size ,b33d ac 50 c1 LDY $c150 ,b340 86 a4 STX $a4 ,b342 84 a3 STY $a3 ,b344 ae 3f c1 LDX $c13f ; get message box position ,b347 ac 40 c1 LDY $c140 ,b34a 60 RTS >b34b ; -- set position and get size for clear button area ] descr: ] Prepare for clear button area ] input: ] x,y = button position ] $c004 = button width ] output: ] $fd-$ff = drawing position ] x = area width (button width + 3) ] y = area height ,b34b 20 f2 91 JSR $91f2 ; set drawing position relative to message box ,b34e 18 CLC ,b34f ad 04 c0 LDA $c004 ,b352 69 03 ADC #$03 ,b354 aa TAX ; x = text width + 13 ,b355 a0 12 LDY #$12 ; y = 12 ,b357 60 RTS >b358 ; -- set default left button text address (OK) ] descr: ] Set default OK text address ] input: ] $94,$95 = message box data pointer ,b358 a0 02 LDY #$02 ,b35a a9 54 LDA #$54 ,b35c 91 94 STA ($94),Y ,b35e c8 INY ,b35f a9 c1 LDA #$c1 ,b361 91 94 STA ($94),Y ,b363 60 RTS >b364 ; -- set default right button text address (CANCEL) ] descr: ] Set default CANCEL text address ] input: ] $94,$95 = message box data pointer ,b364 a0 04 LDY #$04 ,b366 a9 57 LDA #$57 ,b368 91 94 STA ($94),Y ,b36a c8 INY ,b36b a9 c1 LDA #$c1 ,b36d 91 94 STA ($94),Y ,b36f 60 RTS # call #50 - SAVE ZERO-PAGE REGISTERS IN STACK AREA >b370 ; -- save set of zero-page registers in stack area ] descr: ] Save zero-page registers in stack area ] input: ] $8b-$8f,$94-$96,$9b,$9c,$9e,$9f,$a3-$aa,$c3,$c4 ] $f7-$ff ,b370 a0 1e LDY #$1e ,b372 b9 a0 b3 LDA $b3a0,Y ,b375 aa TAX ,b376 b5 00 LDA $00,X ,b378 99 00 01 STA $0100,Y ,b37b 88 DEY ,b37c 10 f4 BPL $b372 ,b37e 60 RTS # call #51 - RESTORE ZERO-PAGE REGISTERS AND SELECT TOP WINDOW >b37f ; -- restore zero-page registers and top window data ] descr: ] Restore zero-page registers and select top window ] calls: ] $b391 = restore zero-page regsiters ] $8f93 = select window ,b37f 20 91 b3 JSR $b391 ; restore zero-page registers ,b382 ad 23 c0 LDA $c023 ; any window open? ,b385 f0 09 BEQ $b390 ,b387 ae 24 c0 LDX $c024 ; top window ,b38a ac 25 c0 LDY $c025 ,b38d 4c 93 8f JMP $8f93 ; select window (recall window data) ,b390 60 RTS # call #57 - RESTORE ZERO-PAGE REGISTERS FROM STACK AREA >b391 ; -- restore zero-page registers from stack area ] descr: ] Restore zero-page registers from stack area ] output: ] $8b-$8f,$94-$96,$9b,$9c,$9e,$9f,$a3-$aa,$c3,$c4 ] $f7-$ff ,b391 a0 1e LDY #$1e ,b393 b9 a0 b3 LDA $b3a0,Y ,b396 aa TAX ,b397 b9 00 01 LDA $0100,Y ,b39a 95 00 STA $00,X ,b39c 88 DEY ,b39d 10 f4 BPL $b393 ,b39f 60 RTS >b3a0 ; -- list of temporary zero-page registers to save :b3a0 a3 a4 a5 a6 a7 a8 a9 aa :b3a8 f7 c3 c4 9e 9f 96 8b 8c :b3b0 8d 8e 8f 94 95 9b 9c f8 :b3b8 f9 fa fb fc fd fe ff >b3bf ; -- unused :b3bf 00 00 00 00 00 00 00 00 :b3c7 00 # call #4e - AUTODETECT INPUT DEVICE >b3c8 ; -- autodetect input device ] descr: ] Autodetect input device ] Clear keyboard buffer ] calls: ] $b457 = test mouse present ] output: ] $c01b = input device configration ] $bd = active input device configuration ] $03d3,$03d4 = initial mouse position ,b3c8 08 PHP ,b3c9 78 SEI ,b3ca a9 40 LDA #$40 ; read mouse in port 1 ,b3cc 20 57 b4 JSR $b457 ; test mouse present ,b3cf d0 4a BNE $b41b ,b3d1 a9 80 LDA #$80 ; read mouse in port 2 ,b3d3 20 57 b4 JSR $b457 ; test mouse present ,b3d6 d0 47 BNE $b41f ,b3d8 a2 ff LDX #$ff ,b3da 8e 00 dc STX $dc00 ; deactivate keyboard lines ,b3dd ad 01 dc LDA $dc01 ; test joystick in port 1 ,b3e0 29 0f AND #$0f ,b3e2 f0 04 BEQ $b3e8 ,b3e4 c9 0f CMP #$0f ,b3e6 d0 2b BNE $b413 ,b3e8 ad 00 dc LDA $dc00 ; test joystick in port 2 ,b3eb 29 1f AND #$1f ,b3ed f0 04 BEQ $b3f3 ,b3ef c9 1f CMP #$1f ,b3f1 d0 24 BNE $b417 ,b3f3 a2 00 LDX #$00 ,b3f5 8e 03 dc STX $dc03 ; data direction port B = in ,b3f8 ca DEX ,b3f9 8e 02 dc STX $dc02 ; data direction port A = out ,b3fc ca DEX ,b3fd 8e 00 dc STX $dc00 ; activate keyboard line 1 ,b400 ae 01 dc LDX $dc01 ; any function key pressed? ,b403 e0 ef CPX #$ef ,b405 f0 0c BEQ $b413 ; select joystick in port 1 ,b407 e0 bf CPX #$bf ,b409 f0 08 BEQ $b413 ,b40b e0 f7 CPX #$f7 ,b40d f0 04 BEQ $b413 ,b40f e0 df CPX #$df ,b411 d0 c5 BNE $b3d8 ; wait until any device responds ,b413 a9 00 LDA #$00 ; joystick in port 1 ,b415 f0 0a BEQ $b421 ,b417 a9 80 LDA #$80 ; joystick in port 2 ,b419 d0 06 BNE $b421 ,b41b a9 40 LDA #$40 ; mouse in port 1 ,b41d d0 02 BNE $b421 ,b41f a9 c0 LDA #$c0 ; mouse in port 2 ,b421 8d 1b c0 STA $c01b ; save selected device ,b424 a5 bd LDA $bd ,b426 29 3f AND #$3f ; keep acceleration and speed ,b428 0d 1b c0 ORA $c01b ,b42b 85 bd STA $bd ,b42d a2 00 LDX #$00 ,b42f 8e 0e dc STX $dc0e ; clear control register, disable IRQ clock ,b432 86 c6 STX $c6 ; empty keyboard buffer ,b434 8e 03 dc STX $dc03 ,b437 ca DEX ,b438 8e 02 dc STX $dc02 ,b43b 8e 00 dc STX $dc00 ; deactivate keyboard lines ,b43e 8e 01 dc STX $dc01 ,b441 a0 04 LDY #$04 ; delay ,b443 ca DEX ,b444 d0 fd BNE $b443 ,b446 88 DEY ,b447 d0 fa BNE $b443 ,b449 ae 19 d4 LDX $d419 ; get current mouse readings ,b44c ac 1a d4 LDY $d41a ,b44f 8e d3 03 STX $03d3 ,b452 8c d4 03 STY $03d4 ,b455 28 PLP ,b456 60 RTS >b457 ; -- check for mouse presence ] descr: ] Test mouse present ] input: ] a = mouse point: $40 - port 1, $80 - port 2 ] output: ] z = 0 - mouse present ,b457 8d 00 dc STA $dc00 ; activate mouse on port 1 or 2 ,b45a a0 04 LDY #$04 ; delay ,b45c a2 00 LDX #$00 ,b45e ca DEX ,b45f d0 fd BNE $b45e ,b461 88 DEY ,b462 d0 fa BNE $b45e ,b464 ae 19 d4 LDX $d419 ; read mouse data ,b467 ac 1a d4 LDY $d41a ,b46a e0 ff CPX #$ff ,b46c d0 02 BNE $b470 ,b46e c0 ff CPY #$ff ,b470 60 RTS >b471 ; -- unused :b471 ff ff ff ff ff ff ff ff :b479 ff ff ff ff ff ff ff ff :b481 ff ff ff ff ff ff ff ff :b489 ff ff ff ff ff ff ff ff :b491 ff ff ff ff ff ff ff ff :b499 ff ff ff ff ff ff ff ff :b4a1 ff ff ff ff ff ff ff ff :b4a9 ff ff ff ff ff ff ff ff :b4b1 ff ff ff ff ff ff ff ff # call #53 - LOAD >b4b9 ; -- load ] descr: ] Load ] input: ] x,y = load address ] $8d = filename length ] $8e,$8f = filename address ] $f7 = device number ] calls: ] $87a1 = disable pointer and pointer interrputs ] $ff90 = control OS messages ] $ffba = set logical file parameters ] $ffbd = set filename ] $c15e = switch rom and load ] $b650 = call service from ROM 0 (read drive error channel) ] $8741 = enable pointer and pointer interrupts ] output: ] $8f = $ff: load error ,b4b9 86 8b STX $8b ; load address ,b4bb 84 8c STY $8c ,b4bd 20 a1 87 JSR $87a1 ; disable pointer and pointer interrupts ,b4c0 a5 a3 LDA $a3 ; save registers ,b4c2 48 PHA ,b4c3 a5 a4 LDA $a4 ,b4c5 48 PHA ,b4c6 a5 94 LDA $94 ,b4c8 48 PHA ,b4c9 a5 95 LDA $95 ,b4cb 48 PHA ,b4cc a5 be LDA $be ,b4ce 48 PHA ,b4cf a5 bd LDA $bd ,b4d1 48 PHA ,b4d2 ad ce 03 LDA $03ce ,b4d5 48 PHA ,b4d6 ad cf 03 LDA $03cf ,b4d9 48 PHA ,b4da a9 00 LDA #$00 ,b4dc 85 a3 STA $a3 ; clear zero page registers used by kernel ,b4de 85 a4 STA $a4 ,b4e0 85 94 STA $94 ,b4e2 85 ba STA $ba ,b4e4 20 90 ff JSR $ff90 ; set kernel messages mode to no messages ,b4e7 a9 01 LDA #$01 ; file number ,b4e9 a0 00 LDY #$00 ; secondary address ,b4eb a6 f7 LDX $f7 ; device number ,b4ed 20 ba ff JSR $ffba ; set file parameters ,b4f0 a5 8d LDA $8d ; file name length ,b4f2 a6 8e LDX $8e ; file name address ,b4f4 a4 8f LDY $8f ,b4f6 20 bd ff JSR $ffbd ; set file name ,b4f9 a6 8b LDX $8b ; load address ,b4fb a4 8c LDY $8c ,b4fd a9 70 LDA #$70 ; rom selection - BASIC ,b4ff 20 5e c1 JSR $c15e ; switch rom and load ,b502 a9 c0 LDA #$c0 ,b504 20 90 ff JSR $ff90 ; switch to full kernel messages ,b507 a6 f7 LDX $f7 ,b509 e0 08 CPX #$08 ; disk ,b50b 90 1f BCC $b52c ,b50d a2 03 LDX #$03 ,b50f 20 50 b6 JSR $b650 ; read drive error channel ,b512 a2 00 LDX #$00 ,b514 a5 90 LDA $90 ,b516 30 0e BMI $b526 ; device not present ,b518 ad 00 02 LDA $0200 ; get error code ,b51b c9 30 CMP #$30 ,b51d d0 07 BNE $b526 ,b51f ad 01 02 LDA $0201 ,b522 c9 30 CMP #$30 ,b524 f0 01 BEQ $b527 ; no error ,b526 ca DEX ; error occured ,b527 86 8f STX $8f ,b529 4c 52 b5 JMP $b552 ,b52c a2 00 LDX #$00 ; tape ,b52e a5 90 LDA $90 ; get ST byte ,b530 f0 01 BEQ $b533 ,b532 ca DEX ; error ,b533 86 8f STX $8f ,b535 a2 00 LDX #$00 ; restore bytes destroyed by tape load procedure ,b537 8e c2 03 STX $03c2 ,b53a 8e c9 03 STX $03c9 ,b53d 8e cc 03 STX $03cc ,b540 8e d0 03 STX $03d0 ,b543 a2 3f LDX #$3f ,b545 a0 01 LDY #$01 ,b547 8e ca 03 STX $03ca ,b54a 8c cb 03 STY $03cb ,b54d a0 c7 LDY #$c7 ,b54f 8c cd 03 STY $03cd ,b552 68 PLA ,b553 8d cf 03 STA $03cf ,b556 68 PLA ,b557 8d ce 03 STA $03ce ,b55a 68 PLA ,b55b 85 bd STA $bd ,b55d 68 PLA ,b55e 85 be STA $be ,b560 68 PLA ,b561 85 95 STA $95 ,b563 68 PLA ,b564 85 94 STA $94 ,b566 68 PLA ,b567 85 a4 STA $a4 ,b569 68 PLA ,b56a 85 a3 STA $a3 ,b56c 4c 41 87 JMP $8741 ; reenable pointer # call #54 - SAVE >b56f ; -- save ] descr: ] Save ] input: ] x,y = end of save address ] $f7 = indirect zero-page pointer to start of save address ] $8d = filename length ] $8e,$8f = filename address ] $aa = device number ] calls: ] $87a1 = disable pointer and pointer interrputs ] $ff90 = control OS messages ] $ffba = set logical file parameters ] $ffbd = set filename ] $c169 = switch rom and save ] $b650 = call service from ROM 0 (read drive error channel) ] $8741 = enable pointer and pointer interrupts ] output: ] $8f = $ff: save error ,b56f 86 8b STX $8b ; save address ,b571 84 8c STY $8c ,b573 20 a1 87 JSR $87a1 ; disable pointer and pointer interrupts ,b576 a5 a3 LDA $a3 ; save registers ,b578 48 PHA ,b579 a5 a4 LDA $a4 ,b57b 48 PHA ,b57c a5 94 LDA $94 ,b57e 48 PHA ,b57f a5 95 LDA $95 ,b581 48 PHA ,b582 a5 be LDA $be ,b584 48 PHA ,b585 a5 bd LDA $bd ,b587 48 PHA ,b588 ad ce 03 LDA $03ce ,b58b 48 PHA ,b58c ad cf 03 LDA $03cf ,b58f 48 PHA ,b590 a9 00 LDA #$00 ,b592 85 a3 STA $a3 ; clear zero page registers used by kernel ,b594 85 a4 STA $a4 ,b596 85 94 STA $94 ,b598 85 ba STA $ba ,b59a 20 90 ff JSR $ff90 ; set kernel messages mode to no messages ,b59d a9 01 LDA #$01 ,b59f a6 aa LDX $aa ,b5a1 a0 00 LDY #$00 ,b5a3 20 ba ff JSR $ffba ; set file parameters ,b5a6 a5 8d LDA $8d ,b5a8 a6 8e LDX $8e ,b5aa a4 8f LDY $8f ,b5ac 20 bd ff JSR $ffbd ; set file name ,b5af a6 8b LDX $8b ; save address ,b5b1 a4 8c LDY $8c ,b5b3 a9 70 LDA #$70 ; rom selection - BASIC ,b5b5 20 69 c1 JSR $c169 ; switch rom and save ,b5b8 08 PHP ,b5b9 a9 c0 LDA #$c0 ,b5bb 20 90 ff JSR $ff90 ; switch to full kernel messages ,b5be a6 aa LDX $aa ; device number ,b5c0 e0 08 CPX #$08 ,b5c2 b0 04 BCS $b5c8 ; disk ,b5c4 28 PLP ,b5c5 4c 2c b5 JMP $b52c ; tape - proceed as with load ,b5c8 a2 03 LDX #$03 ,b5ca 20 50 b6 JSR $b650 ; read drive error channel ,b5cd a2 00 LDX #$00 ,b5cf a5 90 LDA $90 ; ST ,b5d1 30 13 BMI $b5e6 ; device not present ,b5d3 ad 00 02 LDA $0200 ; get error code ,b5d6 c9 30 CMP #$30 ,b5d8 d0 0c BNE $b5e6 ,b5da ad 01 02 LDA $0201 ,b5dd c9 30 CMP #$30 ,b5df d0 05 BNE $b5e6 ,b5e1 28 PLP ; no error ,b5e2 90 04 BCC $b5e8 ,b5e4 b0 01 BCS $b5e7 ; carry indicates save error ,b5e6 28 PLP ,b5e7 ca DEX ,b5e8 86 8f STX $8f ,b5ea 4c 52 b5 JMP $b552 ; rest is the same as load # call #52 - DISABLE DESKTOP, PREPARE FOR BASIC >b5ed ; -- disable desktop ] descr: ] Set BASIC background and foreground (text) colors ] Switch to text mode ] Disable raster interrupt and sprites ] Set interrupt vectore for BASIC bar ] Reset BASIC registers ] Clear MG87 marker ] Clear text screen ] Clear memory area $0800-$ffff ] Enable standard irq timer ] input: ] $c01a = background color ] $c019 = foreground color ] $c01e = border color ] $c01f = BASIC flags ] calls: ] $b61f = switch to text mode ] $8102 = fill memory area ] output: ] $0286 = BASIC text color ] $028a = keyboard repeat flag ] $be = BASIC flags ,b5ed ad 1a c0 LDA $c01a ; background color ,b5f0 8d 21 d0 STA $d021 ,b5f3 ad 19 c0 LDA $c019 ; foreground color ,b5f6 8d 86 02 STA $0286 ; set basic text color ,b5f9 20 1f b6 JSR $b61f ; switch to text mode ,b5fc ad 1a d0 LDA $d01a ; disable raster interrupt ,b5ff 29 fe AND #$fe ,b601 8d 1a d0 STA $d01a ,b604 a9 00 LDA #$00 ; disable sprites ,b606 8d 15 d0 STA $d015 ,b609 20 38 b6 JSR $b638 ; set interrupt vectors for basic ,b60c a0 03 LDY #$03 ,b60e a9 00 LDA #$00 ,b610 85 a3 STA $a3 ; reset serial bus flags ,b612 85 94 STA $94 ,b614 85 c6 STA $c6 ; clear keyboard buffer ,b616 99 fc cf STA $cffc,Y ; clear MG87 marker ,b619 88 DEY ,b61a 10 fa BPL $b616 ,b61c 4c 5e b6 JMP $b65e >b61f ; -- switch to text mode ] descr: ] Switch to text mode ,b61f a9 1b LDA #$1b ; text mode ,b621 a2 97 LDX #$97 ; default vic memory bank ,b623 a0 14 LDY #$14 ; default screen memory ,b625 8d 11 d0 STA $d011 ,b628 78 SEI ,b629 ad 12 d0 LDA $d012 ; wait for vertical retrace ,b62c c9 fb CMP #$fb ,b62e 90 f9 BCC $b629 ,b630 58 CLI ,b631 8e 00 dd STX $dd00 ,b634 8c 18 d0 STY $d018 ,b637 60 RTS >b638 ; -- set interrupt vectors for basic ] descr: ] Set interrupt to text mode ] Restore default NMI vector ] note: ] IRQ vector is set to $dfee, which calls 1:$b700 ,b638 78 SEI ,b639 a2 ee LDX #$ee ,b63b a0 df LDY #$df ,b63d 8e 14 03 STX $0314 ; install BAR interrupt for BASIC ,b640 8c 15 03 STY $0315 ,b643 a5 bd LDA $bd ,b645 29 fc AND #$fc ,b647 85 bd STA $bd ; pointer configuration ,b649 a2 47 LDX #$47 ; restore default NMI service routine ,b64b 8e 18 03 STX $0318 ,b64e 58 CLI ,b64f 60 RTS >b650 ; -- call service from ROM 0 ] descr: ] Switch to ROM 0 and call service via 0:$800c ] input: ] x = service number ] $03 = read drive error channel ,b650 a9 80 LDA #$80 ,b652 48 PHA ,b653 a9 0b LDA #$0b ,b655 48 PHA ,b656 ac 00 de LDY $de00 ; get current rom ,b659 a9 40 LDA #$40 ; switch rom to bank 0 ,b65b 4c 01 de JMP $de01 ; far jump to 0:$800c >b65e ; -- disable desktop cont. ,b65e ad 1f c0 LDA $c01f ; BASIC flags ,b661 29 10 AND #$10 ; key repeat ,b663 d0 02 BNE $b667 ,b665 f0 02 BEQ $b669 ,b667 a9 80 LDA #$80 ; enable key repeat ,b669 8d 8a 02 STA $028a ,b66c ad 1f c0 LDA $c01f ,b66f 29 20 AND #$20 ; keyboard click ,b671 d0 07 BNE $b67a ,b673 a5 be LDA $be ,b675 29 df AND #$df ,b677 4c 7e b6 JMP $b67e ,b67a a5 be LDA $be ,b67c 09 20 ORA #$20 ,b67e 85 be STA $be ,b680 ad 1f c0 LDA $c01f ,b683 29 08 AND #$08 ; cursor blink ,b685 d0 07 BNE $b68e ,b687 a5 be LDA $be ,b689 29 ef AND #$ef ,b68b 4c 92 b6 JMP $b692 ,b68e a5 be LDA $be ,b690 09 10 ORA #$10 ,b692 85 be STA $be ,b694 ad 1f c0 LDA $c01f ,b697 29 04 AND #$04 ; disable numeric keyboard ,b699 d0 07 BNE $b6a2 ,b69b a5 be LDA $be ,b69d 29 f7 AND #$f7 ,b69f 4c a6 b6 JMP $b6a6 ,b6a2 a5 be LDA $be ,b6a4 09 08 ORA #$08 ,b6a6 85 be STA $be ,b6a8 a5 bd LDA $bd ,b6aa 09 40 ORA #$40 ,b6ac 85 bd STA $bd ; ? ,b6ae ad 1e c0 LDA $c01e ; border color ,b6b1 8d 20 d0 STA $d020 ,b6b4 78 SEI ,b6b5 a9 2f LDA #$2f ,b6b7 85 00 STA $00 ,b6b9 a9 33 LDA #$33 ; disable I/O ,b6bb 85 01 STA $01 ,b6bd a9 20 LDA #$20 ,b6bf a2 04 LDX #$04 ,b6c1 a0 04 LDY #$04 ,b6c3 20 02 81 JSR $8102 ; clear screen ,b6c6 a9 00 LDA #$00 ,b6c8 a2 f8 LDX #$f8 ,b6ca a0 08 LDY #$08 ,b6cc 20 02 81 JSR $8102 ; clear entire memory ,b6cf a9 37 LDA #$37 ,b6d1 85 01 STA $01 ; default memory configuration ,b6d3 a9 01 LDA #$01 ,b6d5 8d 0e dc STA $dc0e ; enable std. irq timer ,b6d8 58 CLI ,b6d9 60 RTS >b6da ; -- unused :b6da 00 00 00 00 00 00 00 00 :b6e2 00 00 00 00 00 00 00 00 :b6ea 00 00 00 00 00 00 00 00 :b6f2 00 00 00 00 00 00 00 00 :b6fa 00 00 00 00 00 00