From 3c4eca168126c65144648669a6ede7395485ea05 Mon Sep 17 00:00:00 2001 From: Quinn Dunki Date: Mon, 1 Sep 2014 11:18:36 -0700 Subject: [PATCH] - New version of WGPrint that handles scrolling and clipping much better --- ReadMe.md | 7 + WeeGUI.xcodeproj/project.pbxproj | 2 + gui.lst | 2939 ++++++++++++++++-------------- gui.s | 48 +- guidemo.dsk | Bin 143360 -> 143360 bytes macros.s | 12 +- memory.s | 50 +- painting.s | 125 +- views.s | 71 +- 9 files changed, 1857 insertions(+), 1397 deletions(-) create mode 100644 ReadMe.md diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..2cd1dee --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,7 @@ + +Known issues +------------ + +- Negative cursor positions unsupported +- Positive scroll values unsupported + diff --git a/WeeGUI.xcodeproj/project.pbxproj b/WeeGUI.xcodeproj/project.pbxproj index 980e621..fae5090 100644 --- a/WeeGUI.xcodeproj/project.pbxproj +++ b/WeeGUI.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 70D435B119A0137F001BFD9B /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; 70D435B219A013AF001BFD9B /* gui.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = gui.s; sourceTree = ""; }; 70D435B419A0141F001BFD9B /* guidemo.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = guidemo.s; sourceTree = ""; }; + 70E84C3019B4ED4300159159 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 70F1DB4A19A56CDA00321637 /* macros.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = macros.s; sourceTree = ""; }; 70F1DB4B19A56D6300321637 /* switches.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = switches.s; sourceTree = ""; }; 70F1DB5619A6B02900321637 /* painting.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = painting.s; sourceTree = ""; }; @@ -23,6 +24,7 @@ 70D435A619A012CF001BFD9B = { isa = PBXGroup; children = ( + 70E84C3019B4ED4300159159 /* README.md */, 70D435B119A0137F001BFD9B /* Makefile */, 70F1DB4A19A56CDA00321637 /* macros.s */, 70F1DB4B19A56D6300321637 /* switches.s */, diff --git a/gui.lst b/gui.lst index 1673fa1..b82b5d6 100644 --- a/gui.lst +++ b/gui.lst @@ -160,7 +160,11 @@ Current file: gui.s 004000 2 asl 004000 2 asl 004000 2 asl -004000 2 asl ; Records are 8 bytes wide +004000 2 asl +004000 2 asl +004000 2 asl +004000 2 asl +004000 2 asl ; Records are 16 bytes wide 004000 2 tay 004000 2 .endmacro 004000 2 @@ -171,7 +175,11 @@ Current file: gui.s 004000 2 asl 004000 2 asl 004000 2 asl -004000 2 asl ; Records are 8 bytes wide +004000 2 asl +004000 2 asl +004000 2 asl +004000 2 asl +004000 2 asl ; Records are 16 bytes wide 004000 2 tax 004000 2 .endmacro 004000 2 @@ -191,1380 +199,1609 @@ Current file: gui.s 004000 1 ; Main 004000 1 004000 1 main: -004000 1 20 33 40 jsr begin80cols -004003 1 20 C0 40 jsr WGClearScreen +004000 1 20 3D 40 jsr begin80cols +004003 1 20 CA 40 jsr WGClearScreen 004006 1 -004006 1 A9 A4 lda #testView +00400B 1 A9 48 lda #>testView 00400D 1 8D 07 00 sta PARAM1 -004010 1 20 46 44 jsr WGCreateView +004010 1 20 05 45 jsr WGCreateView 004013 1 004013 1 A9 00 lda #0 -004015 1 20 FB 44 jsr WGSelectView +004015 1 20 BE 45 jsr WGSelectView 004018 1 -004018 1 20 AC 44 jsr WGPaintView +004018 1 20 6B 45 jsr WGPaintView 00401B 1 -00401B 1 A2 04 ldx #4 -00401D 1 A0 03 ldy #3 -00401F 1 20 17 45 jsr WGSetCursor +00401B 1 A2 05 ldx #5 +00401D 1 A0 00 ldy #0 +00401F 1 20 D7 45 jsr WGSetCursor 004022 1 -004022 1 ; lda #-4 -004022 1 ; jsr WGScrollX -004022 1 ; lda #-3 -004022 1 ; jsr WGScrollY -004022 1 -004022 1 A9 B2 lda #testStr -004029 1 8D 07 00 sta PARAM1 -00402C 1 20 95 43 jsr WGPrintASCII -00402F 1 -00402F 1 ; lda #1 -00402F 1 ; sta PARAM0 -00402F 1 ; lda #1 -00402F 1 ; sta PARAM1 -00402F 1 ; lda #2 -00402F 1 ; sta PARAM2 -00402F 1 ; lda #2 -00402F 1 ; sta PARAM3 -00402F 1 ; ldx #'Q'+$80 -00402F 1 ; jsr WGFillRect -00402F 1 ; jsr WGStrokeRect -00402F 1 ; jmp loop -00402F 1 ; jsr waitForKey -00402F 1 -00402F 1 ; jmp tortureTestRects -00402F 1 -00402F 1 loop: -00402F 1 ; lda #'Q' + $80 -00402F 1 ; jsr COUT -00402F 1 4C 2F 40 jmp loop -004032 1 60 rts ; This seems to work for returning to BASIC.SYSTEM, but I don't think it's right -004033 1 -004033 1 -004033 1 -004033 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004033 1 ; begin80cols -004033 1 ; Enables 80 column mode (and enhanced video firmware) -004033 1 begin80cols: -004033 1 A9 A0 lda #$a0 -004035 1 20 00 C3 jsr $c300 -004038 1 8D 51 C0 SETSWITCH TEXTON -00403B 1 8D 54 C0 SETSWITCH PAGE2OFF -00403E 1 8D 0D C0 SETSWITCH COL80ON -004041 1 8D 01 C0 SETSWITCH STORE80ON -004044 1 60 rts -004045 1 -004045 1 -004045 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004045 1 ; waitForKey -004045 1 ; Spinlocks until a key is pressed -004045 1 waitForKey: -004045 1 AD 10 C0 lda KBDSTRB -004048 1 10 FB bpl waitForKey -00404A 1 60 rts -00404B 1 -00404B 1 -00404B 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -00404B 1 ; read80ColSwitch -00404B 1 ; Returns value of the 80 col switch on //c and //c+ machines -00404B 1 ; OUT A: Switch state (non-zero=80 cols) -00404B 1 ; NOTE: Untested -00404B 1 read80ColSwitch: -00404B 1 AD 60 C0 lda $c060 -00404E 1 10 03 bpl read80ColSwitch_40 -004050 1 A9 01 lda #$1 -004052 1 60 rts -004053 1 -004053 1 read80ColSwitch_40: -004053 1 A9 00 lda #$0 -004055 1 60 rts -004056 1 -004056 1 -004056 1 ; Code modules -004056 1 .include "utility.s" -004056 2 ; -004056 2 ; utility.s -004056 2 ; General utilities for 6502 -004056 2 ; -004056 2 ; Created by Quinn Dunki on 8/15/14. -004056 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. -004056 2 ; -004056 2 -004056 2 -004056 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004056 2 ; delay -004056 2 ; Sleeps for ~1 second -004056 2 ; -004056 2 delay: -004056 2 48 8A 48 98 SAVE_AXY -00405A 2 48 -00405B 2 -00405B 2 A0 CE ldy #$ce ; Loop a bunch -00405D 2 delayOuter: -00405D 2 A2 FF ldx #$ff -00405F 2 delayInner: -00405F 2 EA nop -004060 2 EA nop -004061 2 EA nop -004062 2 EA nop -004063 2 EA nop -004064 2 EA nop -004065 2 EA nop -004066 2 CA dex -004067 2 D0 F6 bne delayInner -004069 2 88 dey -00406A 2 D0 F1 bne delayOuter -00406C 2 -00406C 2 68 A8 68 AA RESTORE_AXY -004070 2 68 -004071 2 60 rts -004072 2 -004072 2 -004072 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004072 2 ; delayShort -004072 2 ; Sleeps for ~1/30th second -004072 2 ; -004072 2 delayShort: -004072 2 48 8A 48 98 SAVE_AXY -004076 2 48 -004077 2 -004077 2 A0 06 ldy #$06 ; Loop a bit -004079 2 delayShortOuter: -004079 2 A2 FF ldx #$ff -00407B 2 delayShortInner: -00407B 2 EA nop -00407C 2 EA nop -00407D 2 EA nop -00407E 2 EA nop -00407F 2 EA nop -004080 2 EA nop -004081 2 EA nop -004082 2 CA dex -004083 2 D0 F6 bne delayShortInner -004085 2 88 dey -004086 2 D0 F1 bne delayShortOuter -004088 2 -004088 2 68 A8 68 AA RESTORE_AXY -00408C 2 68 -00408D 2 60 rts -00408E 2 -00408E 2 -00408E 2 ;;;;;;;;;;;;;;;;;;;;;;; -00408E 2 ; scanHexDigit -00408E 2 ; Scans a 4 bit hex value from an ASCII character -00408E 2 ; A: ASCII character -00408E 2 ; Out A: Hex value -00408E 2 ; -00408E 2 scanHexDigit: -00408E 2 C9 41 cmp #'A' -004090 2 B0 06 bcs scanHexDigitLetter -004092 2 38 sec -004093 2 E9 30 sbc #'0' -004095 2 4C 9B 40 jmp scanHexDigitDone +004022 1 A9 00 lda #0 +004024 1 20 28 46 jsr WGScrollX +004027 1 A9 FE lda #-2 +004029 1 20 4A 46 jsr WGScrollY +00402C 1 +00402C 1 ; lda WG_VIEWCLIP+0 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWCLIP+1 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWCLIP+2 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWCLIP+3 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWCLIP+4 +00402C 1 ; jsr PRBYTE +00402C 1 +00402C 1 ; lda WG_VIEWRECORDS+0 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+1 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+2 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+3 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+4 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+5 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+6 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+7 +00402C 1 ; jsr PRBYTE +00402C 1 ; lda WG_VIEWRECORDS+8 +00402C 1 ; jsr PRBYTE +00402C 1 +00402C 1 A9 5E lda #testStr +004033 1 8D 07 00 sta PARAM1 +004036 1 20 1C 44 jsr WGPrint +004039 1 +004039 1 ; lda #1 +004039 1 ; sta PARAM0 +004039 1 ; lda #1 +004039 1 ; sta PARAM1 +004039 1 ; lda #2 +004039 1 ; sta PARAM2 +004039 1 ; lda #2 +004039 1 ; sta PARAM3 +004039 1 ; ldx #'Q'+$80 +004039 1 ; jsr WGFillRect +004039 1 ; jsr WGStrokeRect +004039 1 ; jmp loop +004039 1 ; jsr waitForKey +004039 1 +004039 1 ; jmp tortureTestRects +004039 1 +004039 1 loop: +004039 1 ; lda #'Q' + $80 +004039 1 ; jsr COUT +004039 1 4C 39 40 jmp loop +00403C 1 60 rts ; This seems to work for returning to BASIC.SYSTEM, but I don't think it's right +00403D 1 +00403D 1 +00403D 1 +00403D 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00403D 1 ; begin80cols +00403D 1 ; Enables 80 column mode (and enhanced video firmware) +00403D 1 begin80cols: +00403D 1 A9 A0 lda #$a0 +00403F 1 20 00 C3 jsr $c300 +004042 1 8D 51 C0 SETSWITCH TEXTON +004045 1 8D 54 C0 SETSWITCH PAGE2OFF +004048 1 8D 0D C0 SETSWITCH COL80ON +00404B 1 8D 01 C0 SETSWITCH STORE80ON +00404E 1 60 rts +00404F 1 +00404F 1 +00404F 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00404F 1 ; waitForKey +00404F 1 ; Spinlocks until a key is pressed +00404F 1 waitForKey: +00404F 1 AD 10 C0 lda KBDSTRB +004052 1 10 FB bpl waitForKey +004054 1 60 rts +004055 1 +004055 1 +004055 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004055 1 ; read80ColSwitch +004055 1 ; Returns value of the 80 col switch on //c and //c+ machines +004055 1 ; OUT A: Switch state (non-zero=80 cols) +004055 1 ; NOTE: Untested +004055 1 read80ColSwitch: +004055 1 AD 60 C0 lda $c060 +004058 1 10 03 bpl read80ColSwitch_40 +00405A 1 A9 01 lda #$1 +00405C 1 60 rts +00405D 1 +00405D 1 read80ColSwitch_40: +00405D 1 A9 00 lda #$0 +00405F 1 60 rts +004060 1 +004060 1 +004060 1 ; Code modules +004060 1 .include "utility.s" +004060 2 ; +004060 2 ; utility.s +004060 2 ; General utilities for 6502 +004060 2 ; +004060 2 ; Created by Quinn Dunki on 8/15/14. +004060 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. +004060 2 ; +004060 2 +004060 2 +004060 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004060 2 ; delay +004060 2 ; Sleeps for ~1 second +004060 2 ; +004060 2 delay: +004060 2 48 8A 48 98 SAVE_AXY +004064 2 48 +004065 2 +004065 2 A0 CE ldy #$ce ; Loop a bunch +004067 2 delayOuter: +004067 2 A2 FF ldx #$ff +004069 2 delayInner: +004069 2 EA nop +00406A 2 EA nop +00406B 2 EA nop +00406C 2 EA nop +00406D 2 EA nop +00406E 2 EA nop +00406F 2 EA nop +004070 2 CA dex +004071 2 D0 F6 bne delayInner +004073 2 88 dey +004074 2 D0 F1 bne delayOuter +004076 2 +004076 2 68 A8 68 AA RESTORE_AXY +00407A 2 68 +00407B 2 60 rts +00407C 2 +00407C 2 +00407C 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00407C 2 ; delayShort +00407C 2 ; Sleeps for ~1/30th second +00407C 2 ; +00407C 2 delayShort: +00407C 2 48 8A 48 98 SAVE_AXY +004080 2 48 +004081 2 +004081 2 A0 06 ldy #$06 ; Loop a bit +004083 2 delayShortOuter: +004083 2 A2 FF ldx #$ff +004085 2 delayShortInner: +004085 2 EA nop +004086 2 EA nop +004087 2 EA nop +004088 2 EA nop +004089 2 EA nop +00408A 2 EA nop +00408B 2 EA nop +00408C 2 CA dex +00408D 2 D0 F6 bne delayShortInner +00408F 2 88 dey +004090 2 D0 F1 bne delayShortOuter +004092 2 +004092 2 68 A8 68 AA RESTORE_AXY +004096 2 68 +004097 2 60 rts 004098 2 -004098 2 scanHexDigitLetter: -004098 2 38 sec -004099 2 E9 37 sbc #55 -00409B 2 -00409B 2 scanHexDigitDone: -00409B 2 60 rts -00409C 2 -00409C 2 -00409C 2 ;;;;;;;;;;;;;;;;;;;;;;; -00409C 2 ; scanHex8 -00409C 2 ; Scans an 8 bit hex value from a string -00409C 2 ; PARAM0: Pointer to string (LSB) -00409C 2 ; PARAM1: Pointer to string (MSB) -00409C 2 ; Y: Offset into string -00409C 2 ; Out A: 8-bit hex value -00409C 2 ; Side effects: Clobbers Y and S0 -00409C 2 ; -00409C 2 scanHex8: -00409C 2 B1 06 lda (PARAM0),y -00409E 2 20 8E 40 jsr scanHexDigit -0040A1 2 0A asl -0040A2 2 0A asl -0040A3 2 0A asl -0040A4 2 0A asl -0040A5 2 8D 19 00 sta SCRATCH0 ; Stash first digit for later -0040A8 2 -0040A8 2 C8 iny -0040A9 2 B1 06 lda (PARAM0),y -0040AB 2 20 8E 40 jsr scanHexDigit -0040AE 2 0D 19 00 ora SCRATCH0 -0040B1 2 C8 iny ; Be nice and advance Y to end -0040B2 2 60 rts -0040B3 2 -0040B3 2 -0040B3 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -0040B3 2 ; WGStrLen -0040B3 2 ; Finds the length of a null-terminated string -0040B3 2 ; PARAM0: String pointer, LSB -0040B3 2 ; PARAM1: String pointer, MSB -0040B3 2 ; Return: A: String length, not including null -0040B3 2 ; -0040B3 2 WGStrLen: -0040B3 2 5A phy -0040B4 2 -0040B4 2 A0 00 ldy #$0 -0040B6 2 WGStrLen_loop: -0040B6 2 B1 06 lda (PARAM0),y -0040B8 2 F0 03 beq WGStrLen_done -0040BA 2 C8 iny -0040BB 2 80 F9 bra WGStrLen_loop +004098 2 +004098 2 ;;;;;;;;;;;;;;;;;;;;;;; +004098 2 ; scanHexDigit +004098 2 ; Scans a 4 bit hex value from an ASCII character +004098 2 ; A: ASCII character +004098 2 ; Out A: Hex value +004098 2 ; +004098 2 scanHexDigit: +004098 2 C9 41 cmp #'A' +00409A 2 B0 06 bcs scanHexDigitLetter +00409C 2 38 sec +00409D 2 E9 30 sbc #'0' +00409F 2 4C A5 40 jmp scanHexDigitDone +0040A2 2 +0040A2 2 scanHexDigitLetter: +0040A2 2 38 sec +0040A3 2 E9 37 sbc #55 +0040A5 2 +0040A5 2 scanHexDigitDone: +0040A5 2 60 rts +0040A6 2 +0040A6 2 +0040A6 2 ;;;;;;;;;;;;;;;;;;;;;;; +0040A6 2 ; scanHex8 +0040A6 2 ; Scans an 8 bit hex value from a string +0040A6 2 ; PARAM0: Pointer to string (LSB) +0040A6 2 ; PARAM1: Pointer to string (MSB) +0040A6 2 ; Y: Offset into string +0040A6 2 ; Out A: 8-bit hex value +0040A6 2 ; Side effects: Clobbers Y and S0 +0040A6 2 ; +0040A6 2 scanHex8: +0040A6 2 B1 06 lda (PARAM0),y +0040A8 2 20 98 40 jsr scanHexDigit +0040AB 2 0A asl +0040AC 2 0A asl +0040AD 2 0A asl +0040AE 2 0A asl +0040AF 2 8D 19 00 sta SCRATCH0 ; Stash first digit for later +0040B2 2 +0040B2 2 C8 iny +0040B3 2 B1 06 lda (PARAM0),y +0040B5 2 20 98 40 jsr scanHexDigit +0040B8 2 0D 19 00 ora SCRATCH0 +0040BB 2 C8 iny ; Be nice and advance Y to end +0040BC 2 60 rts 0040BD 2 -0040BD 2 WGStrLen_done: -0040BD 2 98 tya -0040BE 2 7A ply -0040BF 2 60 rts -0040C0 2 -0040C0 2 -0040C0 2 -0040C0 1 .include "painting.s" -0040C0 2 ; -0040C0 2 ; painting.s -0040C0 2 ; Rendering routines for 80 column text elements -0040C0 2 ; -0040C0 2 ; Created by Quinn Dunki on 8/15/14. -0040C0 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. -0040C0 2 ; -0040C0 2 -0040C0 2 -0040C0 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -0040C0 2 ; WGClearScreen -0040C0 2 ; Clears the text screen (assumes 80 cols) -0040C0 2 ; Side effects: Clobbers BASL,BASH -0040C0 2 ; -0040C0 2 WGClearScreen: -0040C0 2 -0040C0 2 48 8A 48 98 SAVE_AXY -0040C4 2 48 -0040C5 2 8D 54 C0 SETSWITCH PAGE2OFF -0040C8 2 A2 17 ldx #23 +0040BD 2 +0040BD 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0040BD 2 ; WGStrLen +0040BD 2 ; Finds the length of a null-terminated string +0040BD 2 ; PARAM0: String pointer, LSB +0040BD 2 ; PARAM1: String pointer, MSB +0040BD 2 ; Return: A: String length, not including null +0040BD 2 ; +0040BD 2 WGStrLen: +0040BD 2 5A phy +0040BE 2 +0040BE 2 A0 00 ldy #$0 +0040C0 2 WGStrLen_loop: +0040C0 2 B1 06 lda (PARAM0),y +0040C2 2 F0 03 beq WGStrLen_done +0040C4 2 C8 iny +0040C5 2 80 F9 bra WGStrLen_loop +0040C7 2 +0040C7 2 WGStrLen_done: +0040C7 2 98 tya +0040C8 2 7A ply +0040C9 2 60 rts 0040CA 2 -0040CA 2 WGClearScreen_lineLoop: 0040CA 2 -0040CA 2 BD 8C 46 lda TEXTLINES_L,x ; Compute video memory address of line -0040CD 2 8D 28 00 sta BASL -0040D0 2 BD 74 46 lda TEXTLINES_H,x -0040D3 2 8D 29 00 sta BASH -0040D6 2 -0040D6 2 A0 27 ldy #39 -0040D8 2 A9 A0 lda #' ' + $80 -0040DA 2 -0040DA 2 WGClearScreen_charLoop: -0040DA 2 91 28 sta (BASL),y -0040DC 2 8D 55 C0 SETSWITCH PAGE2ON -0040DF 2 91 28 sta (BASL),y -0040E1 2 8D 54 C0 SETSWITCH PAGE2OFF -0040E4 2 88 dey -0040E5 2 10 F3 bpl WGClearScreen_charLoop -0040E7 2 -0040E7 2 CA dex -0040E8 2 10 E0 bpl WGClearScreen_lineLoop -0040EA 2 -0040EA 2 68 A8 68 AA RESTORE_AXY -0040EE 2 68 -0040EF 2 60 rts -0040F0 2 -0040F0 2 -0040F0 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -0040F0 2 ; WGFillRect -0040F0 2 ; Fills a rectangle (assumes 80 cols) -0040F0 2 ; PARAM0: Left edge -0040F0 2 ; PARAM1: Top edge -0040F0 2 ; PARAM2: Width -0040F0 2 ; PARAM3: Height -0040F0 2 ; X: Character to fill -0040F0 2 ; Side effects: Clobbers BASL,BASH -0040F0 2 ; -0040F0 2 WGFillRect: -0040F0 2 -0040F0 2 48 8A 48 98 SAVE_AXY -0040F4 2 48 -0040F5 2 AD 19 00 48 SAVE_ZPS -0040F9 2 AD 1A 00 48 -0040FD 2 8E 19 00 stx SCRATCH0 -004100 2 -004100 2 18 clc ; Compute bottom edge -004101 2 AD 07 00 lda PARAM1 -004104 2 6D 09 00 adc PARAM3 -004107 2 AA tax -004108 2 -004108 2 WGFillRect_vertLoop: -004108 2 DA phx ; We'll need X back for now, but save the line number -004109 2 -004109 2 BD 8C 46 lda TEXTLINES_L,x ; Compute video memory address of left edge of rect -00410C 2 8D 28 00 sta BASL -00410F 2 BD 74 46 lda TEXTLINES_H,x -004112 2 8D 29 00 sta BASH -004115 2 -004115 2 AD 06 00 lda PARAM0 -004118 2 4A lsr -004119 2 18 clc -00411A 2 6D 28 00 adc BASL -00411D 2 8D 28 00 sta BASL -004120 2 A9 00 lda #$0 -004122 2 6D 29 00 adc BASH -004125 2 8D 29 00 sta BASH -004128 2 -004128 2 AD 06 00 lda PARAM0 ; Left edge even? -00412B 2 29 01 and #$01 -00412D 2 D0 39 bne WGFillRect_horzLoopOdd -00412F 2 -00412F 2 ; CASE 1: Left edge even-aligned, even width -00412F 2 8D 54 C0 SETSWITCH PAGE2OFF -004132 2 AD 08 00 lda PARAM2 -004135 2 4A lsr -004136 2 A8 tay ; Iterate w/2 -004137 2 88 dey -004138 2 5A phy ; We'll reuse this calculation for the odd columns +0040CA 2 +0040CA 1 .include "painting.s" +0040CA 2 ; +0040CA 2 ; painting.s +0040CA 2 ; Rendering routines for 80 column text elements +0040CA 2 ; +0040CA 2 ; Created by Quinn Dunki on 8/15/14. +0040CA 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. +0040CA 2 ; +0040CA 2 +0040CA 2 +0040CA 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0040CA 2 ; WGClearScreen +0040CA 2 ; Clears the text screen (assumes 80 cols) +0040CA 2 ; Side effects: Clobbers BASL,BASH +0040CA 2 ; +0040CA 2 WGClearScreen: +0040CA 2 +0040CA 2 48 8A 48 98 SAVE_AXY +0040CE 2 48 +0040CF 2 8D 54 C0 SETSWITCH PAGE2OFF +0040D2 2 A2 17 ldx #23 +0040D4 2 +0040D4 2 WGClearScreen_lineLoop: +0040D4 2 +0040D4 2 BD 38 48 lda TEXTLINES_L,x ; Compute video memory address of line +0040D7 2 8D 28 00 sta BASL +0040DA 2 BD 20 48 lda TEXTLINES_H,x +0040DD 2 8D 29 00 sta BASH +0040E0 2 +0040E0 2 A0 27 ldy #39 +0040E2 2 A9 A0 lda #' ' + $80 +0040E4 2 +0040E4 2 WGClearScreen_charLoop: +0040E4 2 91 28 sta (BASL),y +0040E6 2 8D 55 C0 SETSWITCH PAGE2ON +0040E9 2 91 28 sta (BASL),y +0040EB 2 8D 54 C0 SETSWITCH PAGE2OFF +0040EE 2 88 dey +0040EF 2 10 F3 bpl WGClearScreen_charLoop +0040F1 2 +0040F1 2 CA dex +0040F2 2 10 E0 bpl WGClearScreen_lineLoop +0040F4 2 +0040F4 2 68 A8 68 AA RESTORE_AXY +0040F8 2 68 +0040F9 2 60 rts +0040FA 2 +0040FA 2 +0040FA 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0040FA 2 ; WGFillRect +0040FA 2 ; Fills a rectangle (assumes 80 cols) +0040FA 2 ; PARAM0: Left edge +0040FA 2 ; PARAM1: Top edge +0040FA 2 ; PARAM2: Width +0040FA 2 ; PARAM3: Height +0040FA 2 ; X: Character to fill +0040FA 2 ; Side effects: Clobbers BASL,BASH +0040FA 2 ; +0040FA 2 WGFillRect: +0040FA 2 +0040FA 2 48 8A 48 98 SAVE_AXY +0040FE 2 48 +0040FF 2 AD 19 00 48 SAVE_ZPS +004103 2 AD 1A 00 48 +004107 2 8E 19 00 stx SCRATCH0 +00410A 2 +00410A 2 18 clc ; Compute bottom edge +00410B 2 AD 07 00 lda PARAM1 +00410E 2 6D 09 00 adc PARAM3 +004111 2 AA tax +004112 2 +004112 2 WGFillRect_vertLoop: +004112 2 DA phx ; We'll need X back for now, but save the line number +004113 2 +004113 2 BD 38 48 lda TEXTLINES_L,x ; Compute video memory address of left edge of rect +004116 2 8D 28 00 sta BASL +004119 2 BD 20 48 lda TEXTLINES_H,x +00411C 2 8D 29 00 sta BASH +00411F 2 +00411F 2 AD 06 00 lda PARAM0 +004122 2 4A lsr +004123 2 18 clc +004124 2 6D 28 00 adc BASL +004127 2 8D 28 00 sta BASL +00412A 2 A9 00 lda #$0 +00412C 2 6D 29 00 adc BASH +00412F 2 8D 29 00 sta BASH +004132 2 +004132 2 AD 06 00 lda PARAM0 ; Left edge even? +004135 2 29 01 and #$01 +004137 2 D0 39 bne WGFillRect_horzLoopOdd 004139 2 -004139 2 WGFillRect_horzLoopEvenAligned0: ; Draw even columns -004139 2 AD 19 00 lda SCRATCH0 ; Plot the character -00413C 2 91 28 sta (BASL),y -00413E 2 88 dey -00413F 2 10 F8 bpl WGFillRect_horzLoopEvenAligned0 ; Loop for w/2 -004141 2 -004141 2 8D 55 C0 SETSWITCH PAGE2ON ; Prepare for odd columns -004144 2 7A ply ; Iterate w/2 again -004145 2 -004145 2 WGFillRect_horzLoopEvenAligned1: ; Draw odd columns -004145 2 AD 19 00 lda SCRATCH0 ; Plot the character -004148 2 91 28 sta (BASL),y -00414A 2 88 dey -00414B 2 10 F8 bpl WGFillRect_horzLoopEvenAligned1 ; Loop for w/2 -00414D 2 -00414D 2 AD 08 00 lda PARAM2 ; Is width even? -004150 2 29 01 and #$01 -004152 2 F0 0A beq WGFillRect_horzLoopEvenAlignedEvenWidth -004154 2 -004154 2 ; CASE 1a: Left edge even aligned, odd width -004154 2 AD 08 00 lda PARAM2 ; Fill in extra last column -004157 2 4A lsr -004158 2 A8 tay -004159 2 AD 19 00 lda SCRATCH0 ; Plot the character -00415C 2 91 28 sta (BASL),y +004139 2 ; CASE 1: Left edge even-aligned, even width +004139 2 8D 54 C0 SETSWITCH PAGE2OFF +00413C 2 AD 08 00 lda PARAM2 +00413F 2 4A lsr +004140 2 A8 tay ; Iterate w/2 +004141 2 88 dey +004142 2 5A phy ; We'll reuse this calculation for the odd columns +004143 2 +004143 2 WGFillRect_horzLoopEvenAligned0: ; Draw even columns +004143 2 AD 19 00 lda SCRATCH0 ; Plot the character +004146 2 91 28 sta (BASL),y +004148 2 88 dey +004149 2 10 F8 bpl WGFillRect_horzLoopEvenAligned0 ; Loop for w/2 +00414B 2 +00414B 2 8D 55 C0 SETSWITCH PAGE2ON ; Prepare for odd columns +00414E 2 7A ply ; Iterate w/2 again +00414F 2 +00414F 2 WGFillRect_horzLoopEvenAligned1: ; Draw odd columns +00414F 2 AD 19 00 lda SCRATCH0 ; Plot the character +004152 2 91 28 sta (BASL),y +004154 2 88 dey +004155 2 10 F8 bpl WGFillRect_horzLoopEvenAligned1 ; Loop for w/2 +004157 2 +004157 2 AD 08 00 lda PARAM2 ; Is width even? +00415A 2 29 01 and #$01 +00415C 2 F0 0A beq WGFillRect_horzLoopEvenAlignedEvenWidth 00415E 2 -00415E 2 WGFillRect_horzLoopEvenAlignedEvenWidth: -00415E 2 FA plx ; Prepare for next row -00415F 2 CA dex -004160 2 EC 07 00 cpx PARAM1 -004163 2 B0 A3 bcs WGFillRect_vertLoop -004165 2 4C A4 41 jmp WGFillRect_done +00415E 2 ; CASE 1a: Left edge even aligned, odd width +00415E 2 AD 08 00 lda PARAM2 ; Fill in extra last column +004161 2 4A lsr +004162 2 A8 tay +004163 2 AD 19 00 lda SCRATCH0 ; Plot the character +004166 2 91 28 sta (BASL),y 004168 2 -004168 2 WGFillRect_horzLoopOdd: -004168 2 ; CASE 2: Left edge odd-aligned, even width -004168 2 8D 55 C0 SETSWITCH PAGE2ON -00416B 2 AD 08 00 lda PARAM2 -00416E 2 4A lsr -00416F 2 A8 tay ; Iterate w/2 -004170 2 5A phy ; We'll reuse this calculation for the even columns -004171 2 -004171 2 WGFillRect_horzLoopOddAligned0: ; Draw even columns -004171 2 AD 19 00 lda SCRATCH0 ; Plot the character -004174 2 91 28 sta (BASL),y -004176 2 88 dey -004177 2 D0 F8 bne WGFillRect_horzLoopOddAligned0 ; Loop for w/2 -004179 2 -004179 2 8D 54 C0 SETSWITCH PAGE2OFF ; Prepare for odd columns -00417C 2 7A ply ; Iterate w/2 again, shift left 1 -00417D 2 88 dey -00417E 2 -00417E 2 WGFillRect_horzLoopOddAligned1: ; Draw even columns -00417E 2 AD 19 00 lda SCRATCH0 ; Plot the character -004181 2 91 28 sta (BASL),y -004183 2 88 dey -004184 2 10 F8 bpl WGFillRect_horzLoopOddAligned1 ; Loop for w/2 -004186 2 -004186 2 AD 08 00 lda PARAM2 ; Is width even? -004189 2 29 01 and #$01 -00418B 2 F0 0A beq WGFillRect_horzLoopOddAlignedEvenWidth -00418D 2 -00418D 2 ; CASE 2a: Left edge odd aligned, odd width -00418D 2 AD 08 00 lda PARAM2 ; Fill in extra last column -004190 2 4A lsr -004191 2 A8 tay -004192 2 AD 19 00 lda SCRATCH0 ; Plot the character -004195 2 91 28 sta (BASL),y +004168 2 WGFillRect_horzLoopEvenAlignedEvenWidth: +004168 2 FA plx ; Prepare for next row +004169 2 CA dex +00416A 2 EC 07 00 cpx PARAM1 +00416D 2 B0 A3 bcs WGFillRect_vertLoop +00416F 2 4C AE 41 jmp WGFillRect_done +004172 2 +004172 2 WGFillRect_horzLoopOdd: +004172 2 ; CASE 2: Left edge odd-aligned, even width +004172 2 8D 55 C0 SETSWITCH PAGE2ON +004175 2 AD 08 00 lda PARAM2 +004178 2 4A lsr +004179 2 A8 tay ; Iterate w/2 +00417A 2 5A phy ; We'll reuse this calculation for the even columns +00417B 2 +00417B 2 WGFillRect_horzLoopOddAligned0: ; Draw even columns +00417B 2 AD 19 00 lda SCRATCH0 ; Plot the character +00417E 2 91 28 sta (BASL),y +004180 2 88 dey +004181 2 D0 F8 bne WGFillRect_horzLoopOddAligned0 ; Loop for w/2 +004183 2 +004183 2 8D 54 C0 SETSWITCH PAGE2OFF ; Prepare for odd columns +004186 2 7A ply ; Iterate w/2 again, shift left 1 +004187 2 88 dey +004188 2 +004188 2 WGFillRect_horzLoopOddAligned1: ; Draw even columns +004188 2 AD 19 00 lda SCRATCH0 ; Plot the character +00418B 2 91 28 sta (BASL),y +00418D 2 88 dey +00418E 2 10 F8 bpl WGFillRect_horzLoopOddAligned1 ; Loop for w/2 +004190 2 +004190 2 AD 08 00 lda PARAM2 ; Is width even? +004193 2 29 01 and #$01 +004195 2 F0 0A beq WGFillRect_horzLoopOddAlignedEvenWidth 004197 2 -004197 2 WGFillRect_horzLoopOddAlignedEvenWidth: -004197 2 FA plx ; Prepare for next row -004198 2 CA dex -004199 2 EC 07 00 cpx PARAM1 -00419C 2 B0 03 bcs WGFillRect_vertLoopJmp -00419E 2 4C A4 41 jmp WGFillRect_done -0041A1 2 WGFillRect_vertLoopJmp: -0041A1 2 4C 08 41 jmp WGFillRect_vertLoop -0041A4 2 -0041A4 2 WGFillRect_done: -0041A4 2 68 8D 1A 00 RESTORE_ZPS -0041A8 2 68 8D 19 00 -0041AC 2 68 A8 68 AA RESTORE_AXY -0041B0 2 68 -0041B1 2 60 rts -0041B2 2 -0041B2 2 -0041B2 2 -0041B2 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -0041B2 2 ; WGStrokeRect -0041B2 2 ; Strokes a rectangle (assumes 80 cols) -0041B2 2 ; PARAM0: Left edge -0041B2 2 ; PARAM1: Top edge -0041B2 2 ; PARAM2: Width -0041B2 2 ; PARAM3: Height -0041B2 2 ; Side effects: Clobbers BASL,BASH -0041B2 2 ; -0041B2 2 CH_TOP = '_'+$80 -0041B2 2 CH_BOTTOM = 'L';'_'+$80 -0041B2 2 CH_LEFT = 'Z';'_'+$80 -0041B2 2 CH_RIGHT = '_' -0041B2 2 CH_BOTTOMLEFT = 'L' -0041B2 2 CH_BOTTOMRIGHT = '_'+$80 -0041B2 2 -0041B2 2 WGStrokeRect: -0041B2 2 -0041B2 2 48 8A 48 98 SAVE_AXY -0041B6 2 48 -0041B7 2 AD 19 00 48 SAVE_ZPS -0041BB 2 AD 1A 00 48 -0041BF 2 -0041BF 2 ; Top and bottom edges -0041BF 2 ; -0041BF 2 AE 07 00 ldx PARAM1 ; Start with top edge -0041C2 2 CA dex -0041C3 2 A9 DF lda #CH_TOP -0041C5 2 8D 19 00 sta SCRATCH0 -0041C8 2 -0041C8 2 WGStrokeRect_horzEdge: -0041C8 2 BD 8C 46 lda TEXTLINES_L,x ; Compute video memory address of left edge of rect -0041CB 2 8D 28 00 sta BASL -0041CE 2 BD 74 46 lda TEXTLINES_H,x -0041D1 2 8D 29 00 sta BASH -0041D4 2 -0041D4 2 AD 06 00 lda PARAM0 -0041D7 2 4A lsr -0041D8 2 18 clc -0041D9 2 6D 28 00 adc BASL -0041DC 2 8D 28 00 sta BASL -0041DF 2 A9 00 lda #$0 -0041E1 2 6D 29 00 adc BASH -0041E4 2 8D 29 00 sta BASH -0041E7 2 -0041E7 2 AD 06 00 lda PARAM0 ; Left edge even? -0041EA 2 29 01 and #$01 -0041EC 2 D0 45 bne WGStrokeRect_horzLoopOdd -0041EE 2 -0041EE 2 ; CASE 1: Left edge even-aligned, even width -0041EE 2 8D 54 C0 SETSWITCH PAGE2OFF -0041F1 2 AD 08 00 lda PARAM2 -0041F4 2 4A lsr -0041F5 2 A8 tay ; Start at right edge -0041F6 2 88 dey -0041F7 2 5A phy ; We'll reuse this calculation for the odd columns +004197 2 ; CASE 2a: Left edge odd aligned, odd width +004197 2 AD 08 00 lda PARAM2 ; Fill in extra last column +00419A 2 4A lsr +00419B 2 A8 tay +00419C 2 AD 19 00 lda SCRATCH0 ; Plot the character +00419F 2 91 28 sta (BASL),y +0041A1 2 +0041A1 2 WGFillRect_horzLoopOddAlignedEvenWidth: +0041A1 2 FA plx ; Prepare for next row +0041A2 2 CA dex +0041A3 2 EC 07 00 cpx PARAM1 +0041A6 2 B0 03 bcs WGFillRect_vertLoopJmp +0041A8 2 4C AE 41 jmp WGFillRect_done +0041AB 2 WGFillRect_vertLoopJmp: +0041AB 2 4C 12 41 jmp WGFillRect_vertLoop +0041AE 2 +0041AE 2 WGFillRect_done: +0041AE 2 68 8D 1A 00 RESTORE_ZPS +0041B2 2 68 8D 19 00 +0041B6 2 68 A8 68 AA RESTORE_AXY +0041BA 2 68 +0041BB 2 60 rts +0041BC 2 +0041BC 2 +0041BC 2 +0041BC 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0041BC 2 ; WGStrokeRect +0041BC 2 ; Strokes a rectangle (assumes 80 cols) +0041BC 2 ; PARAM0: Left edge +0041BC 2 ; PARAM1: Top edge +0041BC 2 ; PARAM2: Width +0041BC 2 ; PARAM3: Height +0041BC 2 ; Side effects: Clobbers BASL,BASH +0041BC 2 ; +0041BC 2 CH_TOP = '_'+$80 +0041BC 2 CH_BOTTOM = 'L';'_'+$80 +0041BC 2 CH_LEFT = 'Z';'_'+$80 +0041BC 2 CH_RIGHT = '_' +0041BC 2 CH_BOTTOMLEFT = 'L' +0041BC 2 CH_BOTTOMRIGHT = '_'+$80 +0041BC 2 +0041BC 2 WGStrokeRect: +0041BC 2 +0041BC 2 48 8A 48 98 SAVE_AXY +0041C0 2 48 +0041C1 2 AD 19 00 48 SAVE_ZPS +0041C5 2 AD 1A 00 48 +0041C9 2 +0041C9 2 ; Top and bottom edges +0041C9 2 ; +0041C9 2 AE 07 00 ldx PARAM1 ; Start with top edge +0041CC 2 CA dex +0041CD 2 A9 DF lda #CH_TOP +0041CF 2 8D 19 00 sta SCRATCH0 +0041D2 2 +0041D2 2 WGStrokeRect_horzEdge: +0041D2 2 BD 38 48 lda TEXTLINES_L,x ; Compute video memory address of left edge of rect +0041D5 2 8D 28 00 sta BASL +0041D8 2 BD 20 48 lda TEXTLINES_H,x +0041DB 2 8D 29 00 sta BASH +0041DE 2 +0041DE 2 AD 06 00 lda PARAM0 +0041E1 2 4A lsr +0041E2 2 18 clc +0041E3 2 6D 28 00 adc BASL +0041E6 2 8D 28 00 sta BASL +0041E9 2 A9 00 lda #$0 +0041EB 2 6D 29 00 adc BASH +0041EE 2 8D 29 00 sta BASH +0041F1 2 +0041F1 2 AD 06 00 lda PARAM0 ; Left edge even? +0041F4 2 29 01 and #$01 +0041F6 2 D0 45 bne WGStrokeRect_horzLoopOdd 0041F8 2 -0041F8 2 WGStrokeRect_horzLoopEvenAligned0: ; Draw even columns -0041F8 2 AD 19 00 lda SCRATCH0 ; Plot the character -0041FB 2 91 28 sta (BASL),y -0041FD 2 88 dey -0041FE 2 10 F8 bpl WGStrokeRect_horzLoopEvenAligned0 ; Loop for w/2 -004200 2 -004200 2 8D 55 C0 SETSWITCH PAGE2ON ; Prepare for odd columns -004203 2 7A ply ; Start at right edge again -004204 2 -004204 2 WGStrokeRect_horzLoopEvenAligned1: ; Draw odd columns -004204 2 AD 19 00 lda SCRATCH0 ; Plot the character -004207 2 91 28 sta (BASL),y -004209 2 88 dey -00420A 2 10 F8 bpl WGStrokeRect_horzLoopEvenAligned1 ; Loop for w/2 -00420C 2 -00420C 2 AD 08 00 lda PARAM2 ; Is width even? -00420F 2 29 01 and #$01 -004211 2 F0 0A beq WGStrokeRect_horzLoopEvenAlignedEvenWidth -004213 2 -004213 2 ; CASE 1a: Left edge even aligned, odd width -004213 2 ;SETSWITCH PAGE2OFF -004213 2 AD 08 00 lda PARAM2 ; Fill in extra last column -004216 2 4A lsr -004217 2 A8 tay -004218 2 AD 19 00 lda SCRATCH0 ; Plot the character -00421B 2 91 28 sta (BASL),y +0041F8 2 ; CASE 1: Left edge even-aligned, even width +0041F8 2 8D 54 C0 SETSWITCH PAGE2OFF +0041FB 2 AD 08 00 lda PARAM2 +0041FE 2 4A lsr +0041FF 2 A8 tay ; Start at right edge +004200 2 88 dey +004201 2 5A phy ; We'll reuse this calculation for the odd columns +004202 2 +004202 2 WGStrokeRect_horzLoopEvenAligned0: ; Draw even columns +004202 2 AD 19 00 lda SCRATCH0 ; Plot the character +004205 2 91 28 sta (BASL),y +004207 2 88 dey +004208 2 10 F8 bpl WGStrokeRect_horzLoopEvenAligned0 ; Loop for w/2 +00420A 2 +00420A 2 8D 55 C0 SETSWITCH PAGE2ON ; Prepare for odd columns +00420D 2 7A ply ; Start at right edge again +00420E 2 +00420E 2 WGStrokeRect_horzLoopEvenAligned1: ; Draw odd columns +00420E 2 AD 19 00 lda SCRATCH0 ; Plot the character +004211 2 91 28 sta (BASL),y +004213 2 88 dey +004214 2 10 F8 bpl WGStrokeRect_horzLoopEvenAligned1 ; Loop for w/2 +004216 2 +004216 2 AD 08 00 lda PARAM2 ; Is width even? +004219 2 29 01 and #$01 +00421B 2 F0 0A beq WGStrokeRect_horzLoopEvenAlignedEvenWidth 00421D 2 -00421D 2 WGStrokeRect_horzLoopEvenAlignedEvenWidth: -00421D 2 E8 inx -00421E 2 EC 07 00 cpx PARAM1 -004221 2 D0 56 bne WGStrokeRect_vertEdge -004223 2 18 clc ; Prepare for bottom edge -004224 2 AD 07 00 lda PARAM1 -004227 2 6D 09 00 adc PARAM3 -00422A 2 AA tax -00422B 2 A9 4C lda #CH_BOTTOM -00422D 2 8D 19 00 sta SCRATCH0 -004230 2 4C C8 41 jmp WGStrokeRect_horzEdge -004233 2 -004233 2 WGStrokeRect_horzLoopOdd: -004233 2 ; CASE 2: Left edge odd-aligned, even width -004233 2 8D 55 C0 SETSWITCH PAGE2ON -004236 2 AD 08 00 lda PARAM2 -004239 2 4A lsr -00423A 2 A8 tay ; Iterate w/2 -00423B 2 5A phy ; We'll reuse this calculation for the even columns -00423C 2 -00423C 2 WGStrokeRect_horzLoopOddAligned0: ; Draw even columns -00423C 2 AD 19 00 lda SCRATCH0 ; Plot the character -00423F 2 91 28 sta (BASL),y -004241 2 88 dey -004242 2 D0 F8 bne WGStrokeRect_horzLoopOddAligned0 ; Loop for w/2 -004244 2 -004244 2 8D 54 C0 SETSWITCH PAGE2OFF ; Prepare for odd columns -004247 2 7A ply ; Iterate w/2 again, shift left 1 -004248 2 88 dey -004249 2 -004249 2 WGStrokeRect_horzLoopOddAligned1: ; Draw even columns -004249 2 AD 19 00 lda SCRATCH0 ; Plot the character -00424C 2 91 28 sta (BASL),y -00424E 2 88 dey -00424F 2 10 F8 bpl WGStrokeRect_horzLoopOddAligned1 ; Loop for w/2 -004251 2 -004251 2 AD 08 00 lda PARAM2 ; Is width even? -004254 2 29 01 and #$01 -004256 2 F0 0B beq WGStrokeRect_horzLoopOddAlignedEvenWidth -004258 2 -004258 2 ; CASE 2a: Left edge odd aligned, odd width -004258 2 AD 08 00 lda PARAM2 ; Fill in extra last column -00425B 2 3A dec -00425C 2 4A lsr -00425D 2 A8 tay -00425E 2 AD 19 00 lda SCRATCH0 ; Plot the character -004261 2 91 28 sta (BASL),y -004263 2 -004263 2 WGStrokeRect_horzLoopOddAlignedEvenWidth: -004263 2 E8 inx -004264 2 EC 07 00 cpx PARAM1 -004267 2 D0 10 bne WGStrokeRect_vertEdge -004269 2 18 clc ; Prepare for bottom edge -00426A 2 AD 07 00 lda PARAM1 -00426D 2 6D 09 00 adc PARAM3 -004270 2 AA tax -004271 2 A9 4C lda #CH_BOTTOM -004273 2 8D 19 00 sta SCRATCH0 -004276 2 4C C8 41 jmp WGStrokeRect_horzEdge -004279 2 -004279 2 -004279 2 WGStrokeRect_vertEdge: -004279 2 ; Left and right edges -004279 2 ; -004279 2 18 clc -00427A 2 AD 07 00 lda PARAM1 ; Compute bottom edge -00427D 2 6D 09 00 adc PARAM3 -004280 2 8D 19 00 sta SCRATCH0 +00421D 2 ; CASE 1a: Left edge even aligned, odd width +00421D 2 ;SETSWITCH PAGE2OFF +00421D 2 AD 08 00 lda PARAM2 ; Fill in extra last column +004220 2 4A lsr +004221 2 A8 tay +004222 2 AD 19 00 lda SCRATCH0 ; Plot the character +004225 2 91 28 sta (BASL),y +004227 2 +004227 2 WGStrokeRect_horzLoopEvenAlignedEvenWidth: +004227 2 E8 inx +004228 2 EC 07 00 cpx PARAM1 +00422B 2 D0 56 bne WGStrokeRect_vertEdge +00422D 2 18 clc ; Prepare for bottom edge +00422E 2 AD 07 00 lda PARAM1 +004231 2 6D 09 00 adc PARAM3 +004234 2 AA tax +004235 2 A9 4C lda #CH_BOTTOM +004237 2 8D 19 00 sta SCRATCH0 +00423A 2 4C D2 41 jmp WGStrokeRect_horzEdge +00423D 2 +00423D 2 WGStrokeRect_horzLoopOdd: +00423D 2 ; CASE 2: Left edge odd-aligned, even width +00423D 2 8D 55 C0 SETSWITCH PAGE2ON +004240 2 AD 08 00 lda PARAM2 +004243 2 4A lsr +004244 2 A8 tay ; Iterate w/2 +004245 2 5A phy ; We'll reuse this calculation for the even columns +004246 2 +004246 2 WGStrokeRect_horzLoopOddAligned0: ; Draw even columns +004246 2 AD 19 00 lda SCRATCH0 ; Plot the character +004249 2 91 28 sta (BASL),y +00424B 2 88 dey +00424C 2 D0 F8 bne WGStrokeRect_horzLoopOddAligned0 ; Loop for w/2 +00424E 2 +00424E 2 8D 54 C0 SETSWITCH PAGE2OFF ; Prepare for odd columns +004251 2 7A ply ; Iterate w/2 again, shift left 1 +004252 2 88 dey +004253 2 +004253 2 WGStrokeRect_horzLoopOddAligned1: ; Draw even columns +004253 2 AD 19 00 lda SCRATCH0 ; Plot the character +004256 2 91 28 sta (BASL),y +004258 2 88 dey +004259 2 10 F8 bpl WGStrokeRect_horzLoopOddAligned1 ; Loop for w/2 +00425B 2 +00425B 2 AD 08 00 lda PARAM2 ; Is width even? +00425E 2 29 01 and #$01 +004260 2 F0 0B beq WGStrokeRect_horzLoopOddAlignedEvenWidth +004262 2 +004262 2 ; CASE 2a: Left edge odd aligned, odd width +004262 2 AD 08 00 lda PARAM2 ; Fill in extra last column +004265 2 3A dec +004266 2 4A lsr +004267 2 A8 tay +004268 2 AD 19 00 lda SCRATCH0 ; Plot the character +00426B 2 91 28 sta (BASL),y +00426D 2 +00426D 2 WGStrokeRect_horzLoopOddAlignedEvenWidth: +00426D 2 E8 inx +00426E 2 EC 07 00 cpx PARAM1 +004271 2 D0 10 bne WGStrokeRect_vertEdge +004273 2 18 clc ; Prepare for bottom edge +004274 2 AD 07 00 lda PARAM1 +004277 2 6D 09 00 adc PARAM3 +00427A 2 AA tax +00427B 2 A9 4C lda #CH_BOTTOM +00427D 2 8D 19 00 sta SCRATCH0 +004280 2 4C D2 41 jmp WGStrokeRect_horzEdge 004283 2 -004283 2 AE 07 00 ldx PARAM1 ; Start with top edge -004286 2 -004286 2 WGStrokeRect_vertLoop: -004286 2 -004286 2 DA phx ; We'll need X back for now, but save the line number -004287 2 -004287 2 BD 8C 46 lda TEXTLINES_L,x ; Compute video memory address of left edge of rect -00428A 2 8D 28 00 sta BASL -00428D 2 BD 74 46 lda TEXTLINES_H,x -004290 2 8D 29 00 sta BASH -004293 2 -004293 2 AD 06 00 lda PARAM0 -004296 2 3A dec -004297 2 4A lsr -004298 2 18 clc -004299 2 6D 28 00 adc BASL -00429C 2 8D 28 00 sta BASL -00429F 2 A9 00 lda #$0 -0042A1 2 6D 29 00 adc BASH -0042A4 2 8D 29 00 sta BASH -0042A7 2 -0042A7 2 AD 06 00 lda PARAM0 ; Left edge even? -0042AA 2 3A dec -0042AB 2 29 01 and #$01 -0042AD 2 D0 3C bne WGStrokeRect_vertLoopOdd -0042AF 2 -0042AF 2 ; CASE 1: Left edge even-aligned, even width -0042AF 2 8D 55 C0 SETSWITCH PAGE2ON -0042B2 2 A0 00 ldy #$0 -0042B4 2 A9 5A lda #CH_LEFT ; Plot the left edge -0042B6 2 91 28 sta (BASL),y -0042B8 2 -0042B8 2 AD 08 00 lda PARAM2 ; Is width even? -0042BB 2 1A inc -0042BC 2 1A inc -0042BD 2 29 01 and #$01 -0042BF 2 D0 12 bne WGStrokeRect_vertLoopEvenAlignedOddWidth -0042C1 2 -0042C1 2 AD 08 00 lda PARAM2 ; Calculate right edge -0042C4 2 1A inc +004283 2 +004283 2 WGStrokeRect_vertEdge: +004283 2 ; Left and right edges +004283 2 ; +004283 2 18 clc +004284 2 AD 07 00 lda PARAM1 ; Compute bottom edge +004287 2 6D 09 00 adc PARAM3 +00428A 2 8D 19 00 sta SCRATCH0 +00428D 2 +00428D 2 AE 07 00 ldx PARAM1 ; Start with top edge +004290 2 +004290 2 WGStrokeRect_vertLoop: +004290 2 +004290 2 DA phx ; We'll need X back for now, but save the line number +004291 2 +004291 2 BD 38 48 lda TEXTLINES_L,x ; Compute video memory address of left edge of rect +004294 2 8D 28 00 sta BASL +004297 2 BD 20 48 lda TEXTLINES_H,x +00429A 2 8D 29 00 sta BASH +00429D 2 +00429D 2 AD 06 00 lda PARAM0 +0042A0 2 3A dec +0042A1 2 4A lsr +0042A2 2 18 clc +0042A3 2 6D 28 00 adc BASL +0042A6 2 8D 28 00 sta BASL +0042A9 2 A9 00 lda #$0 +0042AB 2 6D 29 00 adc BASH +0042AE 2 8D 29 00 sta BASH +0042B1 2 +0042B1 2 AD 06 00 lda PARAM0 ; Left edge even? +0042B4 2 3A dec +0042B5 2 29 01 and #$01 +0042B7 2 D0 3C bne WGStrokeRect_vertLoopOdd +0042B9 2 +0042B9 2 ; CASE 1: Left edge even-aligned, even width +0042B9 2 8D 55 C0 SETSWITCH PAGE2ON +0042BC 2 A0 00 ldy #$0 +0042BE 2 A9 5A lda #CH_LEFT ; Plot the left edge +0042C0 2 91 28 sta (BASL),y +0042C2 2 +0042C2 2 AD 08 00 lda PARAM2 ; Is width even? 0042C5 2 1A inc -0042C6 2 4A lsr -0042C7 2 3A dec -0042C8 2 A8 tay -0042C9 2 8D 54 C0 SETSWITCH PAGE2OFF -0042CC 2 A9 5F lda #CH_RIGHT ; Plot the right edge -0042CE 2 91 28 sta (BASL),y -0042D0 2 4C E1 42 jmp WGStrokeRect_vertLoopEvenAlignedNextRow -0042D3 2 -0042D3 2 WGStrokeRect_vertLoopEvenAlignedOddWidth: -0042D3 2 ; CASE 1a: Left edge even-aligned, odd width -0042D3 2 8D 55 C0 SETSWITCH PAGE2ON -0042D6 2 AD 08 00 lda PARAM2 ; Calculate right edge -0042D9 2 1A inc -0042DA 2 1A inc -0042DB 2 4A lsr -0042DC 2 A8 tay -0042DD 2 A9 5F lda #CH_RIGHT ; Plot the right edge -0042DF 2 91 28 sta (BASL),y -0042E1 2 -0042E1 2 WGStrokeRect_vertLoopEvenAlignedNextRow: -0042E1 2 FA plx ; Prepare for next row -0042E2 2 E8 inx -0042E3 2 EC 19 00 cpx SCRATCH0 -0042E6 2 D0 9E bne WGStrokeRect_vertLoop -0042E8 2 4C 29 43 jmp WGStrokeRect_done +0042C6 2 1A inc +0042C7 2 29 01 and #$01 +0042C9 2 D0 12 bne WGStrokeRect_vertLoopEvenAlignedOddWidth +0042CB 2 +0042CB 2 AD 08 00 lda PARAM2 ; Calculate right edge +0042CE 2 1A inc +0042CF 2 1A inc +0042D0 2 4A lsr +0042D1 2 3A dec +0042D2 2 A8 tay +0042D3 2 8D 54 C0 SETSWITCH PAGE2OFF +0042D6 2 A9 5F lda #CH_RIGHT ; Plot the right edge +0042D8 2 91 28 sta (BASL),y +0042DA 2 4C EB 42 jmp WGStrokeRect_vertLoopEvenAlignedNextRow +0042DD 2 +0042DD 2 WGStrokeRect_vertLoopEvenAlignedOddWidth: +0042DD 2 ; CASE 1a: Left edge even-aligned, odd width +0042DD 2 8D 55 C0 SETSWITCH PAGE2ON +0042E0 2 AD 08 00 lda PARAM2 ; Calculate right edge +0042E3 2 1A inc +0042E4 2 1A inc +0042E5 2 4A lsr +0042E6 2 A8 tay +0042E7 2 A9 5F lda #CH_RIGHT ; Plot the right edge +0042E9 2 91 28 sta (BASL),y 0042EB 2 -0042EB 2 -0042EB 2 WGStrokeRect_vertLoopOdd: -0042EB 2 ; CASE 2: Left edge odd-aligned, even width -0042EB 2 8D 54 C0 SETSWITCH PAGE2OFF -0042EE 2 A0 00 ldy #$0 -0042F0 2 A9 5A lda #CH_LEFT ; Plot the left edge -0042F2 2 91 28 sta (BASL),y -0042F4 2 -0042F4 2 AD 08 00 lda PARAM2 ; Is width even? -0042F7 2 1A inc -0042F8 2 1A inc -0042F9 2 29 01 and #$01 -0042FB 2 D0 11 bne WGStrokeRect_vertLoopOddAlignedOddWidth -0042FD 2 -0042FD 2 AD 08 00 lda PARAM2 ; Calculate right edge -004300 2 1A inc +0042EB 2 WGStrokeRect_vertLoopEvenAlignedNextRow: +0042EB 2 FA plx ; Prepare for next row +0042EC 2 E8 inx +0042ED 2 EC 19 00 cpx SCRATCH0 +0042F0 2 D0 9E bne WGStrokeRect_vertLoop +0042F2 2 4C 33 43 jmp WGStrokeRect_done +0042F5 2 +0042F5 2 +0042F5 2 WGStrokeRect_vertLoopOdd: +0042F5 2 ; CASE 2: Left edge odd-aligned, even width +0042F5 2 8D 54 C0 SETSWITCH PAGE2OFF +0042F8 2 A0 00 ldy #$0 +0042FA 2 A9 5A lda #CH_LEFT ; Plot the left edge +0042FC 2 91 28 sta (BASL),y +0042FE 2 +0042FE 2 AD 08 00 lda PARAM2 ; Is width even? 004301 2 1A inc -004302 2 4A lsr -004303 2 A8 tay -004304 2 8D 55 C0 SETSWITCH PAGE2ON -004307 2 A9 5F lda #CH_RIGHT ; Plot the right edge -004309 2 91 28 sta (BASL),y -00430B 2 4C 1C 43 jmp WGStrokeRect_vertLoopOddAlignedNextRow -00430E 2 -00430E 2 WGStrokeRect_vertLoopOddAlignedOddWidth: -00430E 2 ; CASE 2a: Left edge odd-aligned, odd width -00430E 2 8D 54 C0 SETSWITCH PAGE2OFF -004311 2 AD 08 00 lda PARAM2 ; Calculate right edge -004314 2 1A inc -004315 2 1A inc -004316 2 4A lsr -004317 2 A8 tay -004318 2 A9 5F lda #CH_RIGHT ; Plot the right edge -00431A 2 91 28 sta (BASL),y -00431C 2 -00431C 2 WGStrokeRect_vertLoopOddAlignedNextRow: -00431C 2 FA plx ; Prepare for next row -00431D 2 E8 inx -00431E 2 EC 19 00 cpx SCRATCH0 -004321 2 D0 03 bne WGStrokeRect_vertLoopJmp -004323 2 4C 29 43 jmp WGStrokeRect_done -004326 2 WGStrokeRect_vertLoopJmp: -004326 2 4C 86 42 jmp WGStrokeRect_vertLoop -004329 2 -004329 2 WGStrokeRect_done: -004329 2 68 8D 1A 00 RESTORE_ZPS -00432D 2 68 8D 19 00 -004331 2 68 A8 68 AA RESTORE_AXY -004335 2 68 -004336 2 60 rts -004337 2 -004337 2 -004337 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004337 2 ; WGPlot -004337 2 ; Plots a character at current cursor position (assumes 80 cols) -004337 2 ; A: Character to plot -004337 2 ; Side effects: Clobbers SCRATCH0,BASL,BASH -004337 2 ; -004337 2 WGPlot: -004337 2 8D 19 00 sta SCRATCH0 -00433A 2 48 8A 48 98 SAVE_AXY -00433E 2 48 -00433F 2 AD 19 00 48 SAVE_ZPS -004343 2 AD 1A 00 48 -004347 2 -004347 2 AE F0 45 ldx WG_CURSORY -00434A 2 BD 8C 46 lda TEXTLINES_L,x ; Compute video memory address of point -00434D 2 8D 28 00 sta BASL -004350 2 BD 74 46 lda TEXTLINES_H,x -004353 2 8D 29 00 sta BASH -004356 2 -004356 2 AD EF 45 lda WG_CURSORX -004359 2 4A lsr -00435A 2 18 clc -00435B 2 6D 28 00 adc BASL -00435E 2 8D 28 00 sta BASL -004361 2 A9 00 lda #$0 -004363 2 6D 29 00 adc BASH -004366 2 8D 29 00 sta BASH -004369 2 -004369 2 AD EF 45 lda WG_CURSORX ; X even? -00436C 2 29 01 and #$01 -00436E 2 D0 0D bne WGPlot_xOdd -004370 2 -004370 2 8D 55 C0 SETSWITCH PAGE2ON ; Plot the character -004373 2 A0 00 ldy #$0 -004375 2 AD 19 00 lda SCRATCH0 -004378 2 91 28 sta (BASL),y -00437A 2 4C 87 43 jmp WGPlot_done -00437D 2 -00437D 2 WGPlot_xOdd: -00437D 2 8D 54 C0 SETSWITCH PAGE2OFF ; Plot the character -004380 2 A0 00 ldy #$0 -004382 2 AD 19 00 lda SCRATCH0 -004385 2 91 28 sta (BASL),y -004387 2 -004387 2 WGPlot_done: -004387 2 68 8D 1A 00 RESTORE_ZPS -00438B 2 68 8D 19 00 -00438F 2 68 A8 68 AA RESTORE_AXY -004393 2 68 -004394 2 60 rts -004395 2 -004395 2 -004395 2 -004395 2 -004395 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004395 2 ; WGPrintASCII -004395 2 ; Prints a null-terminated ASCII string at the current view's -004395 2 ; cursor position. Clips to current view -004395 2 ; PARAM0: String pointer, LSB -004395 2 ; PARAM1: String pointer, MSB -004395 2 ; Side effects: Clobbers BASL,BASH -004395 2 ; -004395 2 WGPrintASCII: -004395 2 48 8A 48 98 SAVE_AXY -004399 2 48 -00439A 2 AD 19 00 48 SAVE_ZPS -00439E 2 AD 1A 00 48 -0043A2 2 -0043A2 2 20 1E 45 jsr WGSyncGlobalCursor -0043A5 2 -0043A5 2 AD F3 45 29 LDY_ACTIVEVIEW -0043A9 2 0F 0A 0A 0A -0043AD 2 0A A8 -0043AF 2 -0043AF 2 C8 iny ; Clip to upper extent -0043B0 2 AD F0 45 lda WG_CURSORY -0043B3 2 D9 F4 45 cmp WG_VIEWRECORDS,y -0043B6 2 90 65 bcc WGPrintASCII_done -0043B8 2 -0043B8 2 B9 F4 45 lda WG_VIEWRECORDS,y ; Clip to lower extent -0043BB 2 C8 iny -0043BC 2 C8 iny -0043BD 2 18 clc -0043BE 2 79 F4 45 adc WG_VIEWRECORDS,y -0043C1 2 3A dec -0043C2 2 CD F0 45 cmp WG_CURSORY -0043C5 2 90 56 bcc WGPrintASCII_done -0043C7 2 -0043C7 2 20 B3 40 jsr WGStrLen ; We'll need the length of the string to clip horizontally -0043CA 2 8D 19 00 sta SCRATCH0 -0043CD 2 -0043CD 2 88 dey ; Clip left/right extents -0043CE 2 88 dey -0043CF 2 88 dey -0043D0 2 AD EF 45 lda WG_CURSORX ; startIndex = -(globalX - windowStartX) -0043D3 2 38 sec -0043D4 2 F9 F4 45 sbc WG_VIEWRECORDS,y -0043D7 2 49 FF eor #$ff -0043D9 2 1A inc -0043DA 2 30 0F bmi WGPrintASCII_leftEdgeStart -0043DC 2 CD 19 00 cmp SCRATCH0 -0043DF 2 B0 3C bcs WGPrintASCII_done ; Entire string is left of window -0043E1 2 -0043E1 2 AA tax ; Starting mid-string on the left -0043E2 2 B9 F4 45 lda WG_VIEWRECORDS,y -0043E5 2 8D EF 45 sta WG_CURSORX -0043E8 2 8A txa -0043E9 2 80 02 bra WGPrintASCII_findRightEdge +004302 2 1A inc +004303 2 29 01 and #$01 +004305 2 D0 11 bne WGStrokeRect_vertLoopOddAlignedOddWidth +004307 2 +004307 2 AD 08 00 lda PARAM2 ; Calculate right edge +00430A 2 1A inc +00430B 2 1A inc +00430C 2 4A lsr +00430D 2 A8 tay +00430E 2 8D 55 C0 SETSWITCH PAGE2ON +004311 2 A9 5F lda #CH_RIGHT ; Plot the right edge +004313 2 91 28 sta (BASL),y +004315 2 4C 26 43 jmp WGStrokeRect_vertLoopOddAlignedNextRow +004318 2 +004318 2 WGStrokeRect_vertLoopOddAlignedOddWidth: +004318 2 ; CASE 2a: Left edge odd-aligned, odd width +004318 2 8D 54 C0 SETSWITCH PAGE2OFF +00431B 2 AD 08 00 lda PARAM2 ; Calculate right edge +00431E 2 1A inc +00431F 2 1A inc +004320 2 4A lsr +004321 2 A8 tay +004322 2 A9 5F lda #CH_RIGHT ; Plot the right edge +004324 2 91 28 sta (BASL),y +004326 2 +004326 2 WGStrokeRect_vertLoopOddAlignedNextRow: +004326 2 FA plx ; Prepare for next row +004327 2 E8 inx +004328 2 EC 19 00 cpx SCRATCH0 +00432B 2 D0 03 bne WGStrokeRect_vertLoopJmp +00432D 2 4C 33 43 jmp WGStrokeRect_done +004330 2 WGStrokeRect_vertLoopJmp: +004330 2 4C 90 42 jmp WGStrokeRect_vertLoop +004333 2 +004333 2 WGStrokeRect_done: +004333 2 68 8D 1A 00 RESTORE_ZPS +004337 2 68 8D 19 00 +00433B 2 68 A8 68 AA RESTORE_AXY +00433F 2 68 +004340 2 60 rts +004341 2 +004341 2 +004341 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004341 2 ; WGPlot +004341 2 ; Plots a character at current cursor position (assumes 80 cols) +004341 2 ; A: Character to plot +004341 2 ; Side effects: Clobbers S0, BASL,BASH +004341 2 ; +004341 2 WGPlot: +004341 2 8D 19 00 sta SCRATCH0 +004344 2 48 8A 48 98 SAVE_AXY +004348 2 48 +004349 2 +004349 2 AE 16 47 ldx WG_CURSORY +00434C 2 BD 38 48 lda TEXTLINES_L,x ; Compute video memory address of point +00434F 2 8D 28 00 sta BASL +004352 2 BD 20 48 lda TEXTLINES_H,x +004355 2 8D 29 00 sta BASH +004358 2 +004358 2 AD 15 47 lda WG_CURSORX +00435B 2 4A lsr +00435C 2 18 clc +00435D 2 6D 28 00 adc BASL +004360 2 8D 28 00 sta BASL +004363 2 A9 00 lda #$0 +004365 2 6D 29 00 adc BASH +004368 2 8D 29 00 sta BASH +00436B 2 +00436B 2 AD 15 47 lda WG_CURSORX ; X even? +00436E 2 29 01 and #$01 +004370 2 D0 0D bne WGPlot_xOdd +004372 2 +004372 2 8D 55 C0 SETSWITCH PAGE2ON ; Plot the character +004375 2 A0 00 ldy #$0 +004377 2 AD 19 00 lda SCRATCH0 +00437A 2 91 28 sta (BASL),y +00437C 2 4C 89 43 jmp WGPlot_done +00437F 2 +00437F 2 WGPlot_xOdd: +00437F 2 8D 54 C0 SETSWITCH PAGE2OFF ; Plot the character +004382 2 A0 00 ldy #$0 +004384 2 AD 19 00 lda SCRATCH0 +004387 2 91 28 sta (BASL),y +004389 2 +004389 2 WGPlot_done: +004389 2 68 A8 68 AA RESTORE_AXY +00438D 2 68 +00438E 2 60 rts +00438F 2 +00438F 2 +00438F 2 +00438F 2 +00438F 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00438F 2 ; WGPrintASCII +00438F 2 ; Prints a null-terminated ASCII string at the current view's +00438F 2 ; cursor position. Clips to current view +00438F 2 ; PARAM0: String pointer, LSB +00438F 2 ; PARAM1: String pointer, MSB +00438F 2 ; Side effects: Clobbers BASL,BASH +00438F 2 ; +00438F 2 WGPrintASCII: +00438F 2 48 8A 48 98 SAVE_AXY +004393 2 48 +004394 2 AD 19 00 48 SAVE_ZPS +004398 2 AD 1A 00 48 +00439C 2 +00439C 2 20 DE 45 jsr WGSyncGlobalCursor +00439F 2 +00439F 2 AD 19 47 29 LDY_ACTIVEVIEW +0043A3 2 0F 0A 0A 0A +0043A7 2 0A 0A 0A 0A +0043AD 2 +0043AD 2 C8 iny ; Clip to upper extent +0043AE 2 AD 16 47 lda WG_CURSORY +0043B1 2 D9 1F 47 cmp WG_VIEWRECORDS,y +0043B4 2 90 58 bcc WGPrintASCII_done +0043B6 2 +0043B6 2 B9 1F 47 lda WG_VIEWRECORDS,y ; Clip to lower extent +0043B9 2 C8 iny +0043BA 2 C8 iny +0043BB 2 18 clc +0043BC 2 79 1F 47 adc WG_VIEWRECORDS,y +0043BF 2 3A dec +0043C0 2 CD 16 47 cmp WG_CURSORY +0043C3 2 90 49 bcc WGPrintASCII_done +0043C5 2 +0043C5 2 20 BD 40 jsr WGStrLen ; We'll need the length of the string to clip horizontally +0043C8 2 8D 19 00 sta SCRATCH0 +0043CB 2 +0043CB 2 88 dey ; Clip left/right extents +0043CC 2 88 dey +0043CD 2 88 dey +0043CE 2 AD 15 47 lda WG_CURSORX ; startIndex = -(globalX - windowStartX) +0043D1 2 38 sec +0043D2 2 F9 1F 47 sbc WG_VIEWRECORDS,y +0043D5 2 49 FF eor #$ff +0043D7 2 1A inc +0043D8 2 30 0F bmi WGPrintASCII_leftEdgeStart +0043DA 2 CD 19 00 cmp SCRATCH0 +0043DD 2 B0 2F bcs WGPrintASCII_done ; Entire string is left of window +0043DF 2 +0043DF 2 AA tax ; Starting mid-string on the left +0043E0 2 B9 1F 47 lda WG_VIEWRECORDS,y +0043E3 2 8D 15 47 sta WG_CURSORX +0043E6 2 8A txa +0043E7 2 80 02 bra WGPrintASCII_findRightEdge +0043E9 2 +0043E9 2 WGPrintASCII_leftEdgeStart: +0043E9 2 A9 00 lda #0 0043EB 2 -0043EB 2 WGPrintASCII_leftEdgeStart: -0043EB 2 A9 00 lda #0 -0043ED 2 -0043ED 2 WGPrintASCII_findRightEdge: -0043ED 2 48 pha ; Stash start index -0043EE 2 -0043EE 2 B9 F4 45 lda WG_VIEWRECORDS,y -0043F1 2 C8 iny -0043F2 2 C8 iny -0043F3 2 18 clc -0043F4 2 79 F4 45 adc WG_VIEWRECORDS,y -0043F7 2 AA tax -0043F8 2 CA dex -0043F9 2 7A ply ; End cursor in X, start index in Y -0043FA 2 -0043FA 2 WGPrintASCII_loop: -0043FA 2 EC EF 45 cpx WG_CURSORX -0043FD 2 90 1E bcc WGPrintASCII_done ; Hit the right edge of the window -0043FF 2 B1 06 lda (PARAM0),y -004401 2 F0 1A beq WGPrintASCII_done ; Hit the end of the string -004403 2 09 80 ora #$80 -004405 2 20 37 43 jsr WGPlot -004408 2 -004408 2 C8 iny -004409 2 18 clc -00440A 2 A9 01 lda #1 -00440C 2 6D EF 45 adc WG_CURSORX -00440F 2 8D EF 45 sta WG_CURSORX -004412 2 A9 00 lda #0 -004414 2 6D F0 45 adc WG_CURSORY -004417 2 8D F0 45 sta WG_CURSORY -00441A 2 4C FA 43 jmp WGPrintASCII_loop -00441D 2 -00441D 2 WGPrintASCII_done: -00441D 2 68 8D 1A 00 RESTORE_ZPS -004421 2 68 8D 19 00 -004425 2 68 A8 68 AA RESTORE_AXY -004429 2 68 -00442A 2 60 rts -00442B 2 -00442B 2 -00442B 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -00442B 2 ; WGPrint -00442B 2 ; Prints a null-terminated Apple string at the current view's -00442B 2 ; cursor position. Clips to current view. -00442B 2 ; PARAM0: String pointer, LSB -00442B 2 ; PARAM1: String pointer, MSB -00442B 2 ; Side effects: Clobbers BASL,BASH -00442B 2 ; -00442B 2 WGPrint: -00442B 2 48 8A 48 98 SAVE_AXY -00442F 2 48 -004430 2 AD 19 00 48 SAVE_ZPS -004434 2 AD 1A 00 48 -004438 2 -004438 2 -004438 2 -004438 2 -004438 2 WGPrint_done: -004438 2 68 8D 1A 00 RESTORE_ZPS -00443C 2 68 8D 19 00 -004440 2 68 A8 68 AA RESTORE_AXY -004444 2 68 -004445 2 60 rts -004446 2 -004446 1 .include "views.s" -004446 2 ; -004446 2 ; views.s -004446 2 ; Management routines for GUI views -004446 2 ; -004446 2 ; Created by Quinn Dunki on 8/15/14. -004446 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. -004446 2 ; -004446 2 -004446 2 -004446 2 -004446 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004446 2 ; WGCreateView -004446 2 ; Creates a new view -004446 2 ; PARAM0: Pointer to configuration string (LSB) -004446 2 ; PARAM1: Pointer to configuration string (MSB) -004446 2 ; -004446 2 ; Configuration string: "STXXYYSWSHVWVH" -004446 2 ; ST: (4:4) Style:ID -004446 2 ; XX: Screen X origin -004446 2 ; YY: Screen Y origin -004446 2 ; SW: Screen width -004446 2 ; SH: Screen height -004446 2 ; VW: View Width -004446 2 ; VH: View Height -004446 2 ; -004446 2 WGCreateView: -004446 2 48 8A 48 98 SAVE_AXY -00444A 2 48 -00444B 2 AD 19 00 48 SAVE_ZPS -00444F 2 AD 1A 00 48 -004453 2 -004453 2 A0 00 ldy #0 -004455 2 20 9C 40 jsr scanHex8 -004458 2 48 pha -004459 2 -004459 2 29 0F and #%00001111 ; Find our new view record -00445B 2 0A asl -00445C 2 0A asl -00445D 2 0A asl -00445E 2 0A asl ; Records are 8 bytes wide -00445F 2 AA tax -004460 2 -004460 2 68 pla ; Cache style nybble for later -004461 2 4A lsr -004462 2 4A lsr -004463 2 4A lsr -004464 2 4A lsr -004465 2 48 pha -004466 2 -004466 2 20 9C 40 jsr scanHex8 -004469 2 9D F4 45 sta WG_VIEWRECORDS,x ; Screen X -00446C 2 E8 inx +0043EB 2 WGPrintASCII_findRightEdge: +0043EB 2 48 pha ; Stash start index +0043EC 2 +0043EC 2 B9 1F 47 lda WG_VIEWRECORDS,y +0043EF 2 C8 iny +0043F0 2 C8 iny +0043F1 2 18 clc +0043F2 2 79 1F 47 adc WG_VIEWRECORDS,y +0043F5 2 AA tax +0043F6 2 CA dex +0043F7 2 7A ply ; End cursor in X, start index in Y +0043F8 2 +0043F8 2 WGPrintASCII_loop: +0043F8 2 EC 15 47 cpx WG_CURSORX +0043FB 2 90 11 bcc WGPrintASCII_done ; Hit the right edge of the window +0043FD 2 B1 06 lda (PARAM0),y +0043FF 2 F0 0D beq WGPrintASCII_done ; Hit the end of the string +004401 2 09 80 ora #$80 +004403 2 20 41 43 jsr WGPlot +004406 2 +004406 2 C8 iny +004407 2 18 clc +004408 2 EE 15 47 inc WG_CURSORX +00440B 2 4C F8 43 jmp WGPrintASCII_loop +00440E 2 +00440E 2 WGPrintASCII_done: +00440E 2 68 8D 1A 00 RESTORE_ZPS +004412 2 68 8D 19 00 +004416 2 68 A8 68 AA RESTORE_AXY +00441A 2 68 +00441B 2 60 rts +00441C 2 +00441C 2 +00441C 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00441C 2 ; WGPrint +00441C 2 ; Prints a null-terminated Apple string at the current view's +00441C 2 ; cursor position. Clips to current view. +00441C 2 ; PARAM0: String pointer, LSB +00441C 2 ; PARAM1: String pointer, MSB +00441C 2 ; Side effects: Clobbers SA,BASL,BASH +00441C 2 ; +00441C 2 WGPrint: +00441C 2 48 8A 48 98 SAVE_AXY +004420 2 48 +004421 2 AD 19 00 48 SAVE_ZPS +004425 2 AD 1A 00 48 +004429 2 +004429 2 20 BD 40 jsr WGStrLen ; We'll need the length of the string +00442C 2 8D 1A 00 sta SCRATCH1 +00442F 2 +00442F 2 AD 19 47 29 LDX_ACTIVEVIEW ; Cache view width for later +004433 2 0F 0A 0A 0A +004437 2 0A 0A 0A 0A +00443D 2 E8 inx +00443E 2 E8 inx +00443F 2 E8 inx +004440 2 E8 inx +004441 2 E8 inx +004442 2 E8 inx +004443 2 E8 inx +004444 2 BD 1F 47 lda WG_VIEWRECORDS,x +004447 2 8D 1F 48 sta WG_SCRATCHA +00444A 2 E8 inx ; Leave X pointing at view height, for later quick access +00444B 2 +00444B 2 A0 00 ldy #0 +00444D 2 +00444D 2 WGPrint_lineLoopFirst: ; Calculating start of first line is slightly different +00444D 2 AD 18 47 lda WG_LOCALCURSORY +004450 2 CD 1B 47 cmp WG_VIEWCLIP+1 +004453 2 90 18 bcc WGPrint_skipToEndFirst ; This line is above the clip box +004455 2 +004455 2 AD 17 47 lda WG_LOCALCURSORX ; Find start of line within clip box +004458 2 CD 1A 47 cmp WG_VIEWCLIP+0 +00445B 2 B0 54 bcs WGPrint_visibleChars +00445D 2 +00445D 2 AD 1A 47 lda WG_VIEWCLIP+0 +004460 2 38 sec ; Line begins before left clip plane +004461 2 ED 17 47 sbc WG_LOCALCURSORX +004464 2 A8 tay ; Advance string index and advance cursor into clip box +004465 2 AD 1A 47 lda WG_VIEWCLIP+0 +004468 2 8D 17 47 sta WG_LOCALCURSORX +00446B 2 80 44 bra WGPrint_visibleChars 00446D 2 -00446D 2 20 9C 40 jsr scanHex8 -004470 2 9D F4 45 sta WG_VIEWRECORDS,x ; Screen Y -004473 2 E8 inx -004474 2 -004474 2 20 9C 40 jsr scanHex8 -004477 2 9D F4 45 sta WG_VIEWRECORDS,x ; Screen Width -00447A 2 E8 inx -00447B 2 -00447B 2 20 9C 40 jsr scanHex8 -00447E 2 9D F4 45 sta WG_VIEWRECORDS,x ; Screen Height -004481 2 E8 inx +00446D 2 WGPrint_skipToEndFirst: +00446D 2 AD 1F 48 lda WG_SCRATCHA ; Skip string index ahead by distance to EOL +004470 2 38 sec +004471 2 ED 17 47 sbc WG_LOCALCURSORX +004474 2 CD 1A 00 cmp SCRATCH1 +004477 2 B0 7E bcs WGPrint_done +004479 2 A8 tay +00447A 2 +00447A 2 AD 1F 48 lda WG_SCRATCHA ; Skip cursor ahead to EOL +00447D 2 8D 17 47 sta WG_LOCALCURSORX +004480 2 80 5C bra WGPrint_nextLine 004482 2 -004482 2 68 pla -004483 2 9D F4 45 sta WG_VIEWRECORDS,x ; Style -004486 2 E8 inx -004487 2 -004487 2 A9 00 lda #0 ; Initialize scrolling -004489 2 9D F4 45 sta WG_VIEWRECORDS,x -00448C 2 E8 inx -00448D 2 9D F4 45 sta WG_VIEWRECORDS,x -004490 2 E8 inx -004491 2 -004491 2 20 9C 40 jsr scanHex8 -004494 2 9D F4 45 sta WG_VIEWRECORDS,x ; View Width -004497 2 E8 inx -004498 2 -004498 2 20 9C 40 jsr scanHex8 -00449B 2 9D F4 45 sta WG_VIEWRECORDS,x ; View Height -00449E 2 -00449E 2 WGCreateView_done: -00449E 2 68 8D 1A 00 RESTORE_ZPS -0044A2 2 68 8D 19 00 -0044A6 2 68 A8 68 AA RESTORE_AXY -0044AA 2 68 -0044AB 2 60 rts -0044AC 2 -0044AC 2 -0044AC 2 -0044AC 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -0044AC 2 ; WGPaintView -0044AC 2 ; Paints the current view -0044AC 2 ; -0044AC 2 WGPaintView: -0044AC 2 48 98 48 SAVE_AY -0044AF 2 AD 06 00 48 SAVE_ZPP -0044B3 2 AD 07 00 48 -0044B7 2 AD 08 00 48 -0044BF 2 -0044BF 2 AD F3 45 29 LDY_ACTIVEVIEW -0044C3 2 0F 0A 0A 0A -0044C7 2 0A A8 -0044C9 2 -0044C9 2 B9 F4 45 lda WG_VIEWRECORDS,y ; Fetch the record -0044CC 2 8D 06 00 sta PARAM0 -0044CF 2 C8 iny -0044D0 2 B9 F4 45 lda WG_VIEWRECORDS,y -0044D3 2 8D 07 00 sta PARAM1 -0044D6 2 C8 iny -0044D7 2 B9 F4 45 lda WG_VIEWRECORDS,y -0044DA 2 8D 08 00 sta PARAM2 -0044DD 2 C8 iny -0044DE 2 B9 F4 45 lda WG_VIEWRECORDS,y -0044E1 2 8D 09 00 sta PARAM3 -0044E4 2 -0044E4 2 20 B2 41 jsr WGStrokeRect -0044E7 2 -0044E7 2 WGPaintView_done: -0044E7 2 68 8D 09 00 RESTORE_ZPP -0044EB 2 68 8D 08 00 -0044EF 2 68 8D 07 00 -0044F7 2 68 A8 68 RESTORE_AY -0044FA 2 60 rts -0044FB 2 -0044FB 2 -0044FB 2 -0044FB 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -0044FB 2 ; WGSelectView -0044FB 2 ; Selects the active view -0044FB 2 ; A: ID -0044FB 2 ; -0044FB 2 WGSelectView: -0044FB 2 48 98 48 SAVE_AY -0044FE 2 8D F3 45 sta WG_ACTIVEVIEW -004501 2 -004501 2 AD F3 45 29 LDY_ACTIVEVIEW -004505 2 0F 0A 0A 0A -004509 2 0A A8 -00450B 2 -00450B 2 ; Initialize cursor to local origin -00450B 2 A9 00 lda #0 -00450D 2 8D F1 45 sta WG_LOCALCURSORX -004510 2 8D F2 45 sta WG_LOCALCURSORY -004513 2 -004513 2 WGSelectView_done: -004513 2 68 A8 68 RESTORE_AY -004516 2 60 rts -004517 2 -004517 2 -004517 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004517 2 ; WGSetCursor -004517 2 ; Sets the current local view cursor -004517 2 ; X: X -004517 2 ; Y: Y -004517 2 ; -004517 2 WGSetCursor: -004517 2 8E F1 45 stx WG_LOCALCURSORX -00451A 2 8C F2 45 sty WG_LOCALCURSORY -00451D 2 60 rts -00451E 2 -00451E 2 -00451E 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -00451E 2 ; WGSyncGlobalCursor -00451E 2 ; Synchronizes the global cursor with the current local view's -00451E 2 ; cursor -00451E 2 ; -00451E 2 WGSyncGlobalCursor: -00451E 2 48 98 48 SAVE_AY -004521 2 -004521 2 ; X -004521 2 AD F3 45 29 LDY_ACTIVEVIEW -004525 2 0F 0A 0A 0A -004529 2 0A A8 -00452B 2 -00452B 2 18 clc ; Transform to viewspace -00452C 2 AD F1 45 lda WG_LOCALCURSORX -00452F 2 79 F4 45 adc WG_VIEWRECORDS,y -004532 2 -004532 2 C8 iny -004533 2 C8 iny -004534 2 C8 iny -004535 2 C8 iny -004536 2 C8 iny -004537 2 18 clc -004538 2 79 F4 45 adc WG_VIEWRECORDS,y ; Transform to scrollspace -00453B 2 8D EF 45 sta WG_CURSORX -00453E 2 -00453E 2 ; Y -00453E 2 AD F3 45 29 LDY_ACTIVEVIEW -004542 2 0F 0A 0A 0A -004546 2 0A A8 -004548 2 C8 iny -004549 2 -004549 2 18 clc ; Transform to viewspace -00454A 2 AD F2 45 lda WG_LOCALCURSORY -00454D 2 79 F4 45 adc WG_VIEWRECORDS,y +004482 2 WGPrint_skipToEnd: +004482 2 98 tya ; Skip string index ahead by distance to EOL +004483 2 18 clc +004484 2 6D 1F 48 adc WG_SCRATCHA +004487 2 CD 1A 00 cmp SCRATCH1 +00448A 2 B0 6A bcs WGPrint_done2 +00448C 2 A8 tay +00448D 2 +00448D 2 AD 1F 48 lda WG_SCRATCHA ; Skip cursor ahead to EOL +004490 2 8D 17 47 sta WG_LOCALCURSORX +004493 2 80 49 bra WGPrint_nextLine +004495 2 +004495 2 WGPrint_lineLoop: +004495 2 AD 18 47 lda WG_LOCALCURSORY +004498 2 CD 1B 47 cmp WG_VIEWCLIP+1 +00449B 2 90 E5 bcc WGPrint_skipToEnd ; This line is above the clip box +00449D 2 +00449D 2 AD 17 47 lda WG_LOCALCURSORX ; Find start of line within clip box +0044A0 2 CD 1A 47 cmp WG_VIEWCLIP+0 +0044A3 2 B0 0C bcs WGPrint_visibleChars +0044A5 2 +0044A5 2 98 tya +0044A6 2 18 clc +0044A7 2 6D 1A 47 adc WG_VIEWCLIP+0 ; Jump ahead by left span +0044AA 2 A8 tay +0044AB 2 +0044AB 2 AD 1A 47 lda WG_VIEWCLIP+0 ; Set cursor to left edge of visible area +0044AE 2 8D 17 47 sta WG_LOCALCURSORX +0044B1 2 +0044B1 2 WGPrint_visibleChars: +0044B1 2 20 DE 45 jsr WGSyncGlobalCursor +0044B4 2 +0044B4 2 WGPrint_charLoop: +0044B4 2 B1 06 lda (PARAM0),y ; Draw current character +0044B6 2 F0 3F beq WGPrint_done +0044B8 2 09 80 ora #$80 +0044BA 2 20 41 43 jsr WGPlot +0044BD 2 C8 iny +0044BE 2 +0044BE 2 EE 15 47 inc WG_CURSORX ; Advance cursors +0044C1 2 EE 17 47 inc WG_LOCALCURSORX +0044C4 2 +0044C4 2 AD 17 47 lda WG_LOCALCURSORX +0044C7 2 CD 1F 48 cmp WG_SCRATCHA ; Check for wrap boundary +0044CA 2 F0 12 beq WGPrint_nextLine +0044CC 2 CD 1C 47 cmp WG_VIEWCLIP+2 ; Check for right clip plane +0044CF 2 F0 02 beq WGPrint_endVisible +0044D1 2 80 E1 bra WGPrint_charLoop +0044D3 2 +0044D3 2 WGPrint_endVisible: +0044D3 2 98 tya +0044D4 2 18 clc +0044D5 2 6D 1E 47 adc WG_VIEWCLIP+4 ; Advance string index by right span +0044D8 2 CD 1A 00 cmp SCRATCH1 +0044DB 2 B0 1A bcs WGPrint_done +0044DD 2 A8 tay +0044DE 2 +0044DE 2 WGPrint_nextLine: +0044DE 2 EE 18 47 inc WG_LOCALCURSORY ; Advance cursor +0044E1 2 AD 18 47 lda WG_LOCALCURSORY +0044E4 2 CD 1D 47 cmp WG_VIEWCLIP+3 ; Check for bottom clip plane +0044E7 2 F0 0E beq WGPrint_done +0044E9 2 DD 1F 47 cmp WG_VIEWRECORDS,x ; Check for bottom of view +0044EC 2 F0 09 beq WGPrint_done +0044EE 2 +0044EE 2 A9 00 lda #0 ; Wrap to next line +0044F0 2 8D 17 47 sta WG_LOCALCURSORX +0044F3 2 4C 95 44 jmp WGPrint_lineLoop +0044F6 2 +0044F6 2 WGPrint_done2: +0044F6 2 00 brk +0044F7 2 WGPrint_done: +0044F7 2 68 8D 1A 00 RESTORE_ZPS +0044FB 2 68 8D 19 00 +0044FF 2 68 A8 68 AA RESTORE_AXY +004503 2 68 +004504 2 60 rts +004505 2 +004505 1 .include "views.s" +004505 2 ; +004505 2 ; views.s +004505 2 ; Management routines for GUI views +004505 2 ; +004505 2 ; Created by Quinn Dunki on 8/15/14. +004505 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. +004505 2 ; +004505 2 +004505 2 +004505 2 +004505 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004505 2 ; WGCreateView +004505 2 ; Creates a new view +004505 2 ; PARAM0: Pointer to ASCII configuration string (LSB) +004505 2 ; PARAM1: Pointer to ASCII configuration string (MSB) +004505 2 ; +004505 2 ; Configuration string: "STXXYYSWSHVWVH" +004505 2 ; ST: (4:4) Style:ID +004505 2 ; XX: Screen X origin +004505 2 ; YY: Screen Y origin +004505 2 ; SW: Screen width +004505 2 ; SH: Screen height +004505 2 ; VW: View Width +004505 2 ; VH: View Height +004505 2 ; +004505 2 WGCreateView: +004505 2 48 8A 48 98 SAVE_AXY +004509 2 48 +00450A 2 AD 19 00 48 SAVE_ZPS +00450E 2 AD 1A 00 48 +004512 2 +004512 2 A0 00 ldy #0 +004514 2 20 A6 40 jsr scanHex8 +004517 2 48 pha +004518 2 +004518 2 29 0F and #%00001111 ; Find our new view record +00451A 2 0A asl +00451B 2 0A asl +00451C 2 0A asl +00451D 2 0A asl ; Records are 8 bytes wide +00451E 2 AA tax +00451F 2 +00451F 2 68 pla ; Cache style nybble for later +004520 2 4A lsr +004521 2 4A lsr +004522 2 4A lsr +004523 2 4A lsr +004524 2 48 pha +004525 2 +004525 2 20 A6 40 jsr scanHex8 +004528 2 9D 1F 47 sta WG_VIEWRECORDS,x ; Screen X +00452B 2 E8 inx +00452C 2 +00452C 2 20 A6 40 jsr scanHex8 +00452F 2 9D 1F 47 sta WG_VIEWRECORDS,x ; Screen Y +004532 2 E8 inx +004533 2 +004533 2 20 A6 40 jsr scanHex8 +004536 2 9D 1F 47 sta WG_VIEWRECORDS,x ; Screen Width +004539 2 E8 inx +00453A 2 +00453A 2 20 A6 40 jsr scanHex8 +00453D 2 9D 1F 47 sta WG_VIEWRECORDS,x ; Screen Height +004540 2 E8 inx +004541 2 +004541 2 68 pla +004542 2 9D 1F 47 sta WG_VIEWRECORDS,x ; Style +004545 2 E8 inx +004546 2 +004546 2 A9 00 lda #0 ; Initialize scrolling +004548 2 9D 1F 47 sta WG_VIEWRECORDS,x +00454B 2 E8 inx +00454C 2 9D 1F 47 sta WG_VIEWRECORDS,x +00454F 2 E8 inx 004550 2 -004550 2 C8 iny -004551 2 C8 iny -004552 2 C8 iny -004553 2 C8 iny -004554 2 C8 iny -004555 2 18 clc -004556 2 79 F4 45 adc WG_VIEWRECORDS,y ; Transform to scrollspace -004559 2 8D F0 45 sta WG_CURSORY -00455C 2 -00455C 2 WGSyncGlobalCursor_done: -00455C 2 68 A8 68 RESTORE_AY -00455F 2 60 rts -004560 2 -004560 2 -004560 2 -004560 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004560 2 ; WGScrollX -004560 2 ; Scrolls the current view horizontally -004560 2 ; A: Delta to scroll -004560 2 ; Side effects: Clobbers A -004560 2 ; -004560 2 WGScrollX: -004560 2 5A phy -004561 2 48 pha -004562 2 AD F3 45 29 LDY_ACTIVEVIEW -004566 2 0F 0A 0A 0A -00456A 2 0A A8 -00456C 2 68 pla -00456D 2 C8 iny -00456E 2 C8 iny -00456F 2 C8 iny -004570 2 C8 iny -004571 2 C8 iny -004572 2 18 clc -004573 2 79 F4 45 adc WG_VIEWRECORDS,y -004576 2 99 F4 45 sta WG_VIEWRECORDS,y -004579 2 -004579 2 WGScrollX_done: -004579 2 7A ply -00457A 2 60 rts -00457B 2 -00457B 2 -00457B 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -00457B 2 ; WGScrollY -00457B 2 ; Scrolls the current view vertically -00457B 2 ; A: Delta to scroll -00457B 2 ; Side effects: Clobbers A -00457B 2 ; -00457B 2 WGScrollY: -00457B 2 5A phy -00457C 2 48 pha -00457D 2 AD F3 45 29 LDY_ACTIVEVIEW -004581 2 0F 0A 0A 0A -004585 2 0A A8 -004587 2 68 pla -004588 2 C8 iny -004589 2 C8 iny -00458A 2 C8 iny -00458B 2 C8 iny -00458C 2 C8 iny -00458D 2 C8 iny -00458E 2 18 clc -00458F 2 79 F4 45 adc WG_VIEWRECORDS,y -004592 2 99 F4 45 sta WG_VIEWRECORDS,y -004595 2 -004595 2 WGScrollY_done: -004595 2 7A ply -004596 2 60 rts -004597 2 -004597 2 -004597 2 -004597 1 .include "unit_test.s" -004597 2 ; -004597 2 ; unit_test.s -004597 2 ; WeeGui -004597 2 ; -004597 2 ; Unit tests of various systems -004597 2 ; -004597 2 ; Created by Quinn Dunki on 8/15/14. -004597 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. -004597 2 ; -004597 2 -004597 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -004597 2 ; tortureTestRects -004597 2 ; Strokes and paints rectangles of many different geometries -004597 2 ; -004597 2 ; Stack: -004597 2 ; Curr X -004597 2 ; Curr Y -004597 2 ; Curr Width -004597 2 ; Curr Height -004597 2 tortureTestRects: -004597 2 20 C0 40 jsr WGClearScreen -00459A 2 -00459A 2 A9 26 lda #38 ; Initialize -00459C 2 48 pha -00459D 2 A9 0B lda #11 -00459F 2 48 pha -0045A0 2 A9 02 lda #2 -0045A2 2 48 pha -0045A3 2 A9 02 lda #2 -0045A5 2 48 pha -0045A6 2 -0045A6 2 tortureTestRectsLoop: -0045A6 2 -0045A6 2 20 C0 40 jsr WGClearScreen -0045A9 2 -0045A9 2 BA tsx -0045AA 2 E8 inx -0045AB 2 BD 00 01 lda $0100,x ; Load Height, then modify -0045AE 2 8D 09 00 sta PARAM3 -0045B1 2 1A inc -0045B2 2 1A inc -0045B3 2 9D 00 01 sta $0100,x -0045B6 2 C9 19 cmp #25 -0045B8 2 B0 2E bcs tortureTestRectsDone -0045BA 2 -0045BA 2 E8 inx ; Load Width, then modify -0045BB 2 BD 00 01 lda $0100,x -0045BE 2 8D 08 00 sta PARAM2 -0045C1 2 1A inc -0045C2 2 1A inc -0045C3 2 1A inc -0045C4 2 1A inc -0045C5 2 1A inc -0045C6 2 1A inc -0045C7 2 9D 00 01 sta $0100,x -0045CA 2 -0045CA 2 E8 inx ; Load Y, then modify -0045CB 2 BD 00 01 lda $0100,x -0045CE 2 8D 07 00 sta PARAM1 -0045D1 2 3A dec -0045D2 2 9D 00 01 sta $0100,x -0045D5 2 -0045D5 2 E8 inx ; Load X, then modify -0045D6 2 BD 00 01 lda $0100,x -0045D9 2 8D 06 00 sta PARAM0 -0045DC 2 3A dec -0045DD 2 3A dec -0045DE 2 3A dec -0045DF 2 9D 00 01 sta $0100,x -0045E2 2 -0045E2 2 ; ldx #'Q'+$80 -0045E2 2 ; jsr WGFillRect -0045E2 2 20 B2 41 jsr WGStrokeRect -0045E5 2 -0045E5 2 ; jsr delayShort -0045E5 2 -0045E5 2 4C A6 45 jmp tortureTestRectsLoop -0045E8 2 -0045E8 2 tortureTestRectsDone: -0045E8 2 68 pla -0045E9 2 68 pla -0045EA 2 68 pla -0045EB 2 68 pla -0045EC 2 4C 97 45 jmp tortureTestRects +004550 2 20 A6 40 jsr scanHex8 +004553 2 9D 1F 47 sta WG_VIEWRECORDS,x ; View Width +004556 2 E8 inx +004557 2 +004557 2 20 A6 40 jsr scanHex8 +00455A 2 9D 1F 47 sta WG_VIEWRECORDS,x ; View Height +00455D 2 +00455D 2 WGCreateView_done: +00455D 2 68 8D 1A 00 RESTORE_ZPS +004561 2 68 8D 19 00 +004565 2 68 A8 68 AA RESTORE_AXY +004569 2 68 +00456A 2 60 rts +00456B 2 +00456B 2 +00456B 2 +00456B 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00456B 2 ; WGPaintView +00456B 2 ; Paints the current view +00456B 2 ; +00456B 2 WGPaintView: +00456B 2 48 98 48 SAVE_AY +00456E 2 AD 06 00 48 SAVE_ZPP +004572 2 AD 07 00 48 +004576 2 AD 08 00 48 +00457E 2 +00457E 2 AD 19 47 29 LDY_ACTIVEVIEW +004582 2 0F 0A 0A 0A +004586 2 0A 0A 0A 0A +00458C 2 +00458C 2 B9 1F 47 lda WG_VIEWRECORDS,y ; Fetch the record +00458F 2 8D 06 00 sta PARAM0 +004592 2 C8 iny +004593 2 B9 1F 47 lda WG_VIEWRECORDS,y +004596 2 8D 07 00 sta PARAM1 +004599 2 C8 iny +00459A 2 B9 1F 47 lda WG_VIEWRECORDS,y +00459D 2 8D 08 00 sta PARAM2 +0045A0 2 C8 iny +0045A1 2 B9 1F 47 lda WG_VIEWRECORDS,y +0045A4 2 8D 09 00 sta PARAM3 +0045A7 2 +0045A7 2 20 BC 41 jsr WGStrokeRect +0045AA 2 +0045AA 2 WGPaintView_done: +0045AA 2 68 8D 09 00 RESTORE_ZPP +0045AE 2 68 8D 08 00 +0045B2 2 68 8D 07 00 +0045BA 2 68 A8 68 RESTORE_AY +0045BD 2 60 rts +0045BE 2 +0045BE 2 +0045BE 2 +0045BE 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0045BE 2 ; WGSelectView +0045BE 2 ; Selects the active view +0045BE 2 ; A: ID +0045BE 2 ; +0045BE 2 WGSelectView: +0045BE 2 48 8A 48 98 SAVE_AXY +0045C2 2 48 +0045C3 2 8D 19 47 sta WG_ACTIVEVIEW +0045C6 2 +0045C6 2 ; Initialize cursor to local origin +0045C6 2 A9 00 lda #0 +0045C8 2 8D 17 47 sta WG_LOCALCURSORX +0045CB 2 8D 18 47 sta WG_LOCALCURSORY +0045CE 2 +0045CE 2 20 6D 46 jsr cacheClipPlanes ; View changed, so clipping cache is stale +0045D1 2 +0045D1 2 WGSelectView_done: +0045D1 2 68 A8 68 AA RESTORE_AXY +0045D5 2 68 +0045D6 2 60 rts +0045D7 2 +0045D7 2 +0045D7 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0045D7 2 ; WGSetCursor +0045D7 2 ; Sets the current local view cursor +0045D7 2 ; X: X +0045D7 2 ; Y: Y +0045D7 2 ; +0045D7 2 WGSetCursor: +0045D7 2 8E 17 47 stx WG_LOCALCURSORX +0045DA 2 8C 18 47 sty WG_LOCALCURSORY +0045DD 2 60 rts +0045DE 2 +0045DE 2 +0045DE 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0045DE 2 ; WGSyncGlobalCursor +0045DE 2 ; Synchronizes the global cursor with the current local view's +0045DE 2 ; cursor +0045DE 2 ; +0045DE 2 WGSyncGlobalCursor: +0045DE 2 48 98 48 SAVE_AY +0045E1 2 +0045E1 2 ; X +0045E1 2 AD 19 47 29 LDY_ACTIVEVIEW +0045E5 2 0F 0A 0A 0A +0045E9 2 0A 0A 0A 0A 0045EF 2 -0045EF 2 -0045EF 1 .include "memory.s" -0045EF 2 ; -0045EF 2 ; memory.s -0045EF 2 ; Memory mapping information -0045EF 2 ; -0045EF 2 ; Created by Quinn Dunki on 8/15/14. -0045EF 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. -0045EF 2 ; -0045EF 2 -0045EF 2 -0045EF 2 ; Reserved locations -0045EF 2 -0045EF 2 INVERSE = $32 -0045EF 2 BASL = $28 -0045EF 2 BASH = $29 -0045EF 2 -0045EF 2 -0045EF 2 ; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS) -0045EF 2 PARAM0 = $06 -0045EF 2 PARAM1 = $07 -0045EF 2 PARAM2 = $08 -0045EF 2 PARAM3 = $09 -0045EF 2 SCRATCH0 = $19 -0045EF 2 SCRATCH1 = $1A -0045EF 2 -0045EF 2 ; Constants -0045EF 2 -0045EF 2 CHAR_NORMAL = $ff -0045EF 2 CHAR_INVERSE = $3f -0045EF 2 CHAR_FLASH = $7f -0045EF 2 -0045EF 2 -0045EF 2 ; ROM entry points -0045EF 2 -0045EF 2 COUT = $fded -0045EF 2 BASCALC = $fbc1 -0045EF 2 -0045EF 2 -0045EF 2 ; System state -0045EF 2 WG_CURSORX: ; In screenspace -0045EF 2 00 .byte 0 -0045F0 2 WG_CURSORY: -0045F0 2 00 .byte 0 -0045F1 2 -0045F1 2 WG_LOCALCURSORX: ; In current viewspace -0045F1 2 00 .byte 0 -0045F2 2 WG_LOCALCURSORY: -0045F2 2 00 .byte 0 -0045F3 2 -0045F3 2 WG_ACTIVEVIEW: -0045F3 2 00 .byte 0 -0045F4 2 -0045F4 2 WG_VIEWRECORDS: -0045F4 2 ; X, Y, Screen Width, Screen Height, Style, X Offset, Y Offset, View Width, View Height -0045F4 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -0045F8 2 00 00 00 00 -0045FC 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004600 2 00 00 00 00 -004604 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004608 2 00 00 00 00 -00460C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004610 2 00 00 00 00 -004614 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004618 2 00 00 00 00 -00461C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004620 2 00 00 00 00 -004624 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004628 2 00 00 00 00 -00462C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004630 2 00 00 00 00 -004634 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004638 2 00 00 00 00 -00463C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004640 2 00 00 00 00 -004644 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004648 2 00 00 00 00 -00464C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004650 2 00 00 00 00 -004654 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004658 2 00 00 00 00 -00465C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004660 2 00 00 00 00 -004664 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004668 2 00 00 00 00 -00466C 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0 -004670 2 00 00 00 00 -004674 2 -004674 2 -004674 2 ; Video memory lookup table -004674 2 TEXTLINES_H: -004674 2 04 .byte $04 ;0 -004675 2 04 .byte $04 ;1 -004676 2 05 .byte $05 ;2 -004677 2 05 .byte $05 ;3 -004678 2 06 .byte $06 ;4 -004679 2 06 .byte $06 ;5 -00467A 2 07 .byte $07 ;6 -00467B 2 07 .byte $07 ;7 -00467C 2 04 .byte $04 ;8 -00467D 2 04 .byte $04 ;9 -00467E 2 05 .byte $05 ;10 -00467F 2 05 .byte $05 ;11 -004680 2 06 .byte $06 ;12 -004681 2 06 .byte $06 ;13 -004682 2 07 .byte $07 ;14 -004683 2 07 .byte $07 ;15 -004684 2 04 .byte $04 ;16 -004685 2 04 .byte $04 ;17 -004686 2 05 .byte $05 ;18 -004687 2 05 .byte $05 ;19 -004688 2 06 .byte $06 ;20 -004689 2 06 .byte $06 ;21 -00468A 2 07 .byte $07 ;22 -00468B 2 07 .byte $07 ;23 +0045EF 2 18 clc ; Transform to viewspace +0045F0 2 AD 17 47 lda WG_LOCALCURSORX +0045F3 2 79 1F 47 adc WG_VIEWRECORDS,y +0045F6 2 +0045F6 2 C8 iny +0045F7 2 C8 iny +0045F8 2 C8 iny +0045F9 2 C8 iny +0045FA 2 C8 iny +0045FB 2 18 clc +0045FC 2 79 1F 47 adc WG_VIEWRECORDS,y ; Transform to scrollspace +0045FF 2 8D 15 47 sta WG_CURSORX +004602 2 +004602 2 ; Y +004602 2 AD 19 47 29 LDY_ACTIVEVIEW +004606 2 0F 0A 0A 0A +00460A 2 0A 0A 0A 0A +004610 2 C8 iny +004611 2 +004611 2 18 clc ; Transform to viewspace +004612 2 AD 18 47 lda WG_LOCALCURSORY +004615 2 79 1F 47 adc WG_VIEWRECORDS,y +004618 2 +004618 2 C8 iny +004619 2 C8 iny +00461A 2 C8 iny +00461B 2 C8 iny +00461C 2 C8 iny +00461D 2 18 clc +00461E 2 79 1F 47 adc WG_VIEWRECORDS,y ; Transform to scrollspace +004621 2 8D 16 47 sta WG_CURSORY +004624 2 +004624 2 WGSyncGlobalCursor_done: +004624 2 68 A8 68 RESTORE_AY +004627 2 60 rts +004628 2 +004628 2 +004628 2 +004628 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004628 2 ; WGScrollX +004628 2 ; Scrolls the current view horizontally +004628 2 ; A: Delta to scroll +004628 2 ; Side effects: Clobbers A +004628 2 ; +004628 2 WGScrollX: +004628 2 5A phy +004629 2 48 pha +00462A 2 AD 19 47 29 LDY_ACTIVEVIEW +00462E 2 0F 0A 0A 0A +004632 2 0A 0A 0A 0A +004638 2 68 pla +004639 2 C8 iny +00463A 2 C8 iny +00463B 2 C8 iny +00463C 2 C8 iny +00463D 2 C8 iny +00463E 2 18 clc +00463F 2 79 1F 47 adc WG_VIEWRECORDS,y +004642 2 99 1F 47 sta WG_VIEWRECORDS,y +004645 2 +004645 2 20 6D 46 jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale +004648 2 +004648 2 WGScrollX_done: +004648 2 7A ply +004649 2 60 rts +00464A 2 +00464A 2 +00464A 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00464A 2 ; WGScrollY +00464A 2 ; Scrolls the current view vertically +00464A 2 ; A: Delta to scroll +00464A 2 ; Side effects: Clobbers A +00464A 2 ; +00464A 2 WGScrollY: +00464A 2 5A phy +00464B 2 48 pha +00464C 2 AD 19 47 29 LDY_ACTIVEVIEW +004650 2 0F 0A 0A 0A +004654 2 0A 0A 0A 0A +00465A 2 68 pla +00465B 2 C8 iny +00465C 2 C8 iny +00465D 2 C8 iny +00465E 2 C8 iny +00465F 2 C8 iny +004660 2 C8 iny +004661 2 18 clc +004662 2 79 1F 47 adc WG_VIEWRECORDS,y +004665 2 99 1F 47 sta WG_VIEWRECORDS,y +004668 2 +004668 2 20 6D 46 jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale +00466B 2 +00466B 2 WGScrollY_done: +00466B 2 7A ply +00466C 2 60 rts +00466D 2 +00466D 2 +00466D 2 +00466D 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +00466D 2 ; cacheClipPlanes +00466D 2 ; Internal routine to cache the clipping planes for the view +00466D 2 ; +00466D 2 cacheClipPlanes: +00466D 2 48 98 48 SAVE_AY +004670 2 +004670 2 ; Compute clip planes in view space +004670 2 AD 19 47 29 LDY_ACTIVEVIEW +004674 2 0F 0A 0A 0A +004678 2 0A 0A 0A 0A +00467E 2 +00467E 2 C8 iny ; Left edge +00467F 2 C8 iny +004680 2 C8 iny +004681 2 C8 iny +004682 2 C8 iny +004683 2 B9 1F 47 lda WG_VIEWRECORDS,y +004686 2 49 FF eor #$ff +004688 2 1A inc +004689 2 8D 1A 47 sta WG_VIEWCLIP+0 00468C 2 -00468C 2 TEXTLINES_L: -00468C 2 00 .byte $00 ;0 -00468D 2 80 .byte $80 ;1 -00468E 2 00 .byte $00 ;2 -00468F 2 80 .byte $80 ;3 -004690 2 00 .byte $00 ;4 -004691 2 80 .byte $80 ;5 -004692 2 00 .byte $00 ;6 -004693 2 80 .byte $80 ;7 -004694 2 28 .byte $28 ;8 -004695 2 A8 .byte $a8 ;9 -004696 2 28 .byte $28 ;10 -004697 2 A8 .byte $a8 ;11 -004698 2 28 .byte $28 ;12 -004699 2 A8 .byte $a8 ;13 -00469A 2 28 .byte $28 ;14 -00469B 2 A8 .byte $a8 ;15 -00469C 2 50 .byte $50 ;16 -00469D 2 D0 .byte $d0 ;17 -00469E 2 50 .byte $50 ;18 -00469F 2 D0 .byte $d0 ;19 -0046A0 2 50 .byte $50 ;20 -0046A1 2 D0 .byte $d0 ;21 -0046A2 2 50 .byte $50 ;22 -0046A3 2 D0 .byte $d0 ;23 -0046A4 2 -0046A4 1 -0046A4 1 -0046A4 1 testView: -0046A4 1 30 30 30 37 .byte "0007033e130404" -0046A8 1 30 33 33 65 -0046AC 1 31 33 30 34 -0046B2 1 -0046B2 1 testStr: -0046B2 1 54 68 69 73 .byte "This is a test of the emergency broadcast system. If this had been a real emergency, you would be dead now.",0 -0046B6 1 20 69 73 20 -0046BA 1 61 20 74 65 -00471E 1 -00471E 1 -00471E 1 -00471E 1 +00468C 2 88 dey ; Right edge +00468D 2 88 dey +00468E 2 88 dey +00468F 2 18 clc +004690 2 79 1F 47 adc WG_VIEWRECORDS,y +004693 2 8D 1C 47 sta WG_VIEWCLIP+2 +004696 2 +004696 2 C8 iny ; Right span (distance from window edge to view edge, in viewspace +004697 2 C8 iny +004698 2 C8 iny +004699 2 C8 iny +00469A 2 C8 iny +00469B 2 B9 1F 47 lda WG_VIEWRECORDS,y +00469E 2 38 sec +00469F 2 ED 1C 47 sbc WG_VIEWCLIP+2 +0046A2 2 8D 1E 47 sta WG_VIEWCLIP+4 +0046A5 2 +0046A5 2 88 dey ; Top edge +0046A6 2 B9 1F 47 lda WG_VIEWRECORDS,y +0046A9 2 49 FF eor #$ff +0046AB 2 1A inc +0046AC 2 8D 1B 47 sta WG_VIEWCLIP+1 +0046AF 2 +0046AF 2 88 dey ; Bottom edge +0046B0 2 88 dey +0046B1 2 88 dey +0046B2 2 18 clc +0046B3 2 79 1F 47 adc WG_VIEWRECORDS,y +0046B6 2 8D 1D 47 sta WG_VIEWCLIP+3 +0046B9 2 +0046B9 2 68 A8 68 RESTORE_AY +0046BC 2 60 rts +0046BD 2 +0046BD 2 +0046BD 2 +0046BD 1 .include "unit_test.s" +0046BD 2 ; +0046BD 2 ; unit_test.s +0046BD 2 ; WeeGui +0046BD 2 ; +0046BD 2 ; Unit tests of various systems +0046BD 2 ; +0046BD 2 ; Created by Quinn Dunki on 8/15/14. +0046BD 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. +0046BD 2 ; +0046BD 2 +0046BD 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +0046BD 2 ; tortureTestRects +0046BD 2 ; Strokes and paints rectangles of many different geometries +0046BD 2 ; +0046BD 2 ; Stack: +0046BD 2 ; Curr X +0046BD 2 ; Curr Y +0046BD 2 ; Curr Width +0046BD 2 ; Curr Height +0046BD 2 tortureTestRects: +0046BD 2 20 CA 40 jsr WGClearScreen +0046C0 2 +0046C0 2 A9 26 lda #38 ; Initialize +0046C2 2 48 pha +0046C3 2 A9 0B lda #11 +0046C5 2 48 pha +0046C6 2 A9 02 lda #2 +0046C8 2 48 pha +0046C9 2 A9 02 lda #2 +0046CB 2 48 pha +0046CC 2 +0046CC 2 tortureTestRectsLoop: +0046CC 2 +0046CC 2 20 CA 40 jsr WGClearScreen +0046CF 2 +0046CF 2 BA tsx +0046D0 2 E8 inx +0046D1 2 BD 00 01 lda $0100,x ; Load Height, then modify +0046D4 2 8D 09 00 sta PARAM3 +0046D7 2 1A inc +0046D8 2 1A inc +0046D9 2 9D 00 01 sta $0100,x +0046DC 2 C9 19 cmp #25 +0046DE 2 B0 2E bcs tortureTestRectsDone +0046E0 2 +0046E0 2 E8 inx ; Load Width, then modify +0046E1 2 BD 00 01 lda $0100,x +0046E4 2 8D 08 00 sta PARAM2 +0046E7 2 1A inc +0046E8 2 1A inc +0046E9 2 1A inc +0046EA 2 1A inc +0046EB 2 1A inc +0046EC 2 1A inc +0046ED 2 9D 00 01 sta $0100,x +0046F0 2 +0046F0 2 E8 inx ; Load Y, then modify +0046F1 2 BD 00 01 lda $0100,x +0046F4 2 8D 07 00 sta PARAM1 +0046F7 2 3A dec +0046F8 2 9D 00 01 sta $0100,x +0046FB 2 +0046FB 2 E8 inx ; Load X, then modify +0046FC 2 BD 00 01 lda $0100,x +0046FF 2 8D 06 00 sta PARAM0 +004702 2 3A dec +004703 2 3A dec +004704 2 3A dec +004705 2 9D 00 01 sta $0100,x +004708 2 +004708 2 ; ldx #'Q'+$80 +004708 2 ; jsr WGFillRect +004708 2 20 BC 41 jsr WGStrokeRect +00470B 2 +00470B 2 ; jsr delayShort +00470B 2 +00470B 2 4C CC 46 jmp tortureTestRectsLoop +00470E 2 +00470E 2 tortureTestRectsDone: +00470E 2 68 pla +00470F 2 68 pla +004710 2 68 pla +004711 2 68 pla +004712 2 4C BD 46 jmp tortureTestRects +004715 2 +004715 2 +004715 1 .include "memory.s" +004715 2 ; +004715 2 ; memory.s +004715 2 ; Memory mapping information +004715 2 ; +004715 2 ; Created by Quinn Dunki on 8/15/14. +004715 2 ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. +004715 2 ; +004715 2 +004715 2 +004715 2 ; Reserved locations +004715 2 +004715 2 INVERSE = $32 +004715 2 BASL = $28 +004715 2 BASH = $29 +004715 2 +004715 2 +004715 2 ; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS) +004715 2 PARAM0 = $06 +004715 2 PARAM1 = $07 +004715 2 PARAM2 = $08 +004715 2 PARAM3 = $09 +004715 2 SCRATCH0 = $19 +004715 2 SCRATCH1 = $1A +004715 2 +004715 2 ; Constants +004715 2 +004715 2 CHAR_NORMAL = $ff +004715 2 CHAR_INVERSE = $3f +004715 2 CHAR_FLASH = $7f +004715 2 +004715 2 +004715 2 ; ROM entry points +004715 2 +004715 2 COUT = $fded +004715 2 BASCALC = $fbc1 +004715 2 PRBYTE = $fdda +004715 2 +004715 2 +004715 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004715 2 ; System state +004715 2 ; +004715 2 WG_CURSORX: ; In screenspace +004715 2 00 .byte 0 +004716 2 WG_CURSORY: +004716 2 00 .byte 0 +004717 2 +004717 2 WG_LOCALCURSORX: ; In current viewspace +004717 2 00 .byte 0 +004718 2 WG_LOCALCURSORY: +004718 2 00 .byte 0 +004719 2 +004719 2 WG_ACTIVEVIEW: +004719 2 00 .byte 0 +00471A 2 +00471A 2 WG_VIEWCLIP: +00471A 2 ; X0,Y0,X1,Y1. Edges of current window, in view space, right span +00471A 2 00 00 00 00 .byte 0,0,0,0,0 +00471E 2 00 +00471F 2 +00471F 2 WG_VIEWRECORDS: +00471F 2 ; X, Y, Screen Width, Screen Height, Style, X Offset, Y Offset, View Width, View Height +00471F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004723 2 00 00 00 00 +004727 2 00 00 00 00 +00472F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004733 2 00 00 00 00 +004737 2 00 00 00 00 +00473F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004743 2 00 00 00 00 +004747 2 00 00 00 00 +00474F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004753 2 00 00 00 00 +004757 2 00 00 00 00 +00475F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004763 2 00 00 00 00 +004767 2 00 00 00 00 +00476F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004773 2 00 00 00 00 +004777 2 00 00 00 00 +00477F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004783 2 00 00 00 00 +004787 2 00 00 00 00 +00478F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004793 2 00 00 00 00 +004797 2 00 00 00 00 +00479F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0047A3 2 00 00 00 00 +0047A7 2 00 00 00 00 +0047AF 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0047B3 2 00 00 00 00 +0047B7 2 00 00 00 00 +0047BF 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0047C3 2 00 00 00 00 +0047C7 2 00 00 00 00 +0047CF 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0047D3 2 00 00 00 00 +0047D7 2 00 00 00 00 +0047DF 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0047E3 2 00 00 00 00 +0047E7 2 00 00 00 00 +0047EF 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0047F3 2 00 00 00 00 +0047F7 2 00 00 00 00 +0047FF 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004803 2 00 00 00 00 +004807 2 00 00 00 00 +00480F 2 00 00 00 00 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +004813 2 00 00 00 00 +004817 2 00 00 00 00 +00481F 2 +00481F 2 WG_SCRATCHA: +00481F 2 00 .byte 0 +004820 2 +004820 2 +004820 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +004820 2 ; Lookup tables +004820 2 ; +004820 2 +004820 2 ; Video memory +004820 2 TEXTLINES_H: +004820 2 04 .byte $04 ;0 +004821 2 04 .byte $04 ;1 +004822 2 05 .byte $05 ;2 +004823 2 05 .byte $05 ;3 +004824 2 06 .byte $06 ;4 +004825 2 06 .byte $06 ;5 +004826 2 07 .byte $07 ;6 +004827 2 07 .byte $07 ;7 +004828 2 04 .byte $04 ;8 +004829 2 04 .byte $04 ;9 +00482A 2 05 .byte $05 ;10 +00482B 2 05 .byte $05 ;11 +00482C 2 06 .byte $06 ;12 +00482D 2 06 .byte $06 ;13 +00482E 2 07 .byte $07 ;14 +00482F 2 07 .byte $07 ;15 +004830 2 04 .byte $04 ;16 +004831 2 04 .byte $04 ;17 +004832 2 05 .byte $05 ;18 +004833 2 05 .byte $05 ;19 +004834 2 06 .byte $06 ;20 +004835 2 06 .byte $06 ;21 +004836 2 07 .byte $07 ;22 +004837 2 07 .byte $07 ;23 +004838 2 +004838 2 TEXTLINES_L: +004838 2 00 .byte $00 ;0 +004839 2 80 .byte $80 ;1 +00483A 2 00 .byte $00 ;2 +00483B 2 80 .byte $80 ;3 +00483C 2 00 .byte $00 ;4 +00483D 2 80 .byte $80 ;5 +00483E 2 00 .byte $00 ;6 +00483F 2 80 .byte $80 ;7 +004840 2 28 .byte $28 ;8 +004841 2 A8 .byte $a8 ;9 +004842 2 28 .byte $28 ;10 +004843 2 A8 .byte $a8 ;11 +004844 2 28 .byte $28 ;12 +004845 2 A8 .byte $a8 ;13 +004846 2 28 .byte $28 ;14 +004847 2 A8 .byte $a8 ;15 +004848 2 50 .byte $50 ;16 +004849 2 D0 .byte $d0 ;17 +00484A 2 50 .byte $50 ;18 +00484B 2 D0 .byte $d0 ;19 +00484C 2 50 .byte $50 ;20 +00484D 2 D0 .byte $d0 ;21 +00484E 2 50 .byte $50 ;22 +00484F 2 D0 .byte $d0 ;23 +004850 2 +004850 1 +004850 1 +004850 1 testView: +004850 1 30 30 30 37 .byte "0007033e13207e" ; 0, 7,3,62,19,126,126 +004854 1 30 33 33 65 +004858 1 31 33 32 30 +00485E 1 +00485E 1 testStr: +00485E 1 54 68 69 73 .byte "This is a test of the emergency broadcast system.",0; If this had been a real emergency, you would be dead now.",0 ; 107 chars +004862 1 20 69 73 20 +004866 1 61 20 74 65 +004890 1 +004890 1 +004890 1 +004890 1 diff --git a/gui.s b/gui.s index de700e7..4f838f9 100644 --- a/gui.s +++ b/gui.s @@ -33,20 +33,50 @@ main: jsr WGPaintView - ldx #4 - ldy #3 + ldx #5 + ldy #0 jsr WGSetCursor -; lda #-4 -; jsr WGScrollX -; lda #-3 -; jsr WGScrollY + lda #0 + jsr WGScrollX + lda #-2 + jsr WGScrollY + +; lda WG_VIEWCLIP+0 +; jsr PRBYTE +; lda WG_VIEWCLIP+1 +; jsr PRBYTE +; lda WG_VIEWCLIP+2 +; jsr PRBYTE +; lda WG_VIEWCLIP+3 +; jsr PRBYTE +; lda WG_VIEWCLIP+4 +; jsr PRBYTE + +; lda WG_VIEWRECORDS+0 +; jsr PRBYTE +; lda WG_VIEWRECORDS+1 +; jsr PRBYTE +; lda WG_VIEWRECORDS+2 +; jsr PRBYTE +; lda WG_VIEWRECORDS+3 +; jsr PRBYTE +; lda WG_VIEWRECORDS+4 +; jsr PRBYTE +; lda WG_VIEWRECORDS+5 +; jsr PRBYTE +; lda WG_VIEWRECORDS+6 +; jsr PRBYTE +; lda WG_VIEWRECORDS+7 +; jsr PRBYTE +; lda WG_VIEWRECORDS+8 +; jsr PRBYTE lda #testStr sta PARAM1 - jsr WGPrintASCII + jsr WGPrint ; lda #1 ; sta PARAM0 @@ -119,10 +149,10 @@ read80ColSwitch_40: testView: - .byte "0007033e130404" + .byte "0007033e13207e" ; 0, 7,3,62,19,126,126 testStr: - .byte "This is a test of the emergency broadcast system. If this had been a real emergency, you would be dead now.",0 + .byte "This is a test of the emergency broadcast system.",0; If this had been a real emergency, you would be dead now.",0 ; 107 chars diff --git a/guidemo.dsk b/guidemo.dsk index b5c43a29565a7d6d2732835e6f946bd01019110f..9ff903c16a98eb0ab3345f4acaa6e260c35d4f9b 100644 GIT binary patch delta 1314 zcmZ`(O>7%Q6n^Uvdz~~yiEzBTv9kjx#koM!9%3vIc9VD}W~Cxg1ga4ArD6s00SOND zfF1QfsF>Q-fRqp%RY6ozIVXlgBgj z=G*VR`QFTw?y9A`>Uy|G32pTCysr*C8XxKh_!;tYAXfUH84f~4g*|s#4mP&?Bk!c1 zO_R;E^8yco!*~ct@2msln_2Sa>}u~NAh+c-k#+texvcYA7Zsbao)(kyXQH2{llP|b zSA%3R-G|0?Xv&Fj=f~6};|XXGCcc}0{4*t>te!g*(}B4LunRh9ZU_otsDIz+;%=5> z;>mJSSrf09lf7#hYd9m~%cJ62x$hsco8|FdI+uIi+E7;h>{_>Y<}Y zrp|~jmL`P~cqkg?yc{zRlWbRwIim_lptg>U3gI<}0n%)Lf0eYtp7P4F`OL z+BG|WiXFt+UBHq_Ng;doe-IwW9)vCai=}x&(tKsoxm|-BbYWq^3mNmnqd)m;jPfzM z(1DD0A#pD&S+2v(>1R$r{>Y}NeR5P}mLu$Pn)$n`+c`8wE~l#|-TKeYmMad({|7K) zW%;q<0fjIXEWJz`kBHZ)eisIm*XCicxr!}>EeKLOb{;p*b?N|*Qm#q4&|SCl7ozk- zjpiSaMRTM3YcNRpK)6IQ(@kwBLapCKY&ljWjWjplKvC*jzBMp4lWkoBEM;qyRwP}^ zpz9}H0|kxJ8upk;X~s2~oVN^Ef3JoU>3nrjE0|2W-q>@^b$EVpeV#)IDH?k;UzH zR!9I|LI(;H;JYx;07gKebig1V$RM4GUm%YP7rlFm8$BR*?Zu`$LhqQg@(LaX|F)!B zBeXInYoi06W(=GB-8@?=UNE%y%CjaX8itf+`)cjwzhS+v0@$bH{+bTm~d5m9(IS$?OyqE J_llyF{syZ8$(a=`F*Q-uQNQJp%i2G1ht`=yNM05$sv`720yX<<0?G@<0 z6eMwE;V9(Pxjzs>h~XN`{?ugg!xBC=OECMYiOGy#W+b67j5^Kc^Ilo$)Hl6*-}iZb z&%fVueJ1YNC+^v=J1k6X{($AY{ZM0L-9dzYMqzr;7i&(`J%gHT=!w`z5BbfS7m{sn z`0%>VSkbJ=2xvBh1KkF~e|6)pyO*n%EV!OCZkBbQ`$MnmZ%vZ=E543jj)!kp@vQFv zEX{=q^rGLIY_iV;v}SZ$4d_2kdK@kk%(+o;)|F?f7-o6uV4X8(Loo-+{&2etY{(2S zEBeQoj_Q@JkX_GZj_f;W$TZY*+Q53wj(S(82Xiho-#q=?A8+^c_T`zyzb(t3Ri#Bm z#z(zvUW^9>f+Z!wt5g)@Q+SB5sL%7suTyMdgha$)kwh_{z(iC9636huql%P_5iIjD zfR1}+0ICd|ny8pK+lrMqH4xPVPDqN1c{z%sad8yDOP((PEGg+yyuI*ARg^?Eg~vom zqHbgs-SI2|a3roo2!vM^JQf#Kf|aCd#*xVwR{0?bT>j?C0+PsTTqFsKq!|v25&`F@ zz*qUsqL*Iz2A~4umL94w7?Jo0!J@opYx?!FsGki0`W-T^wn8nX=_5-%T#=Z$dOd5 zSUD=0*DSEg^i>7cAAD6?$O>L9npP z-T&WBpc(_w_kS?@>C0@o%;UE}jTIH>W-D#>(&j*rx1c$YpxNQE!DB^~ZJ=3u;CA<} zYVWTbAI&$18vLa>KxI_$@cyO?-L-^T{Gm@z3Yr@%UDPrwgy9gp01kpMFU$e7R^-a_ zMr%R2Ew0xYYeq1sfQ1%R616aQ4?(acWKNmTc^Yr;qCb13;dE1FYjZ{J`(191Kt-j_ zcWxB9xesvO2f?SOry)egpSxVoV|QEah6`Okk)^e7aTg}43=}L|W$&EZ+~Ve%Zs>iP zM*X#g=a~Xb!dG>E0lNxad&3euuGvt<#Js%F<^Aa-