From f006d30848c986aa7707e83a1251c931781fea73 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 11 Nov 2021 15:58:18 -0500 Subject: [PATCH] logo_demo: add myst drawing code --- demos/logo_demo/demo.logo | 8 +- demos/logo_demo/hardware.inc | 8 + demos/logo_demo/music.s | 1 + demos/logo_demo/myst_vgi.s | 84 ++++++ demos/logo_demo/rocket.data | 130 +++++++++ demos/logo_demo/rocket.vgi | 146 ++++++++++ demos/logo_demo/vgi_circles.s | 303 ++++++++++++++++++++ demos/logo_demo/vgi_clearscreen.s | 7 + demos/logo_demo/vgi_common.s | 72 +++++ demos/logo_demo/vgi_lines.s | 95 ++++++ demos/logo_demo/vgi_rectangle.s | 462 ++++++++++++++++++++++++++++++ demos/logo_demo/vgi_triangles.s | 96 +++++++ demos/logo_demo/zp.inc | 36 ++- 13 files changed, 1444 insertions(+), 4 deletions(-) create mode 100644 demos/logo_demo/myst_vgi.s create mode 100644 demos/logo_demo/rocket.data create mode 100644 demos/logo_demo/rocket.vgi create mode 100644 demos/logo_demo/vgi_circles.s create mode 100644 demos/logo_demo/vgi_clearscreen.s create mode 100644 demos/logo_demo/vgi_common.s create mode 100644 demos/logo_demo/vgi_lines.s create mode 100644 demos/logo_demo/vgi_rectangle.s create mode 100644 demos/logo_demo/vgi_triangles.s diff --git a/demos/logo_demo/demo.logo b/demos/logo_demo/demo.logo index 2755b03c..d1cf1b04 100644 --- a/demos/logo_demo/demo.logo +++ b/demos/logo_demo/demo.logo @@ -128,6 +128,10 @@ WAIT 180 END TO MYST +CS HT +SETBG 1 +.CALL 23084 +WAIT 180 END TO CREDITS @@ -149,8 +153,8 @@ PRINT "DSR PRINT "OCEAN PRINT "WARGAMES PRINT "PLASMA -POLY -PRINT "MYST +PRINT "POLY +MYST PRINT "CS PRINT [REPEAT 5 [ CTREE ]] CREDITS diff --git a/demos/logo_demo/hardware.inc b/demos/logo_demo/hardware.inc index 2eb9901e..c6df0807 100644 --- a/demos/logo_demo/hardware.inc +++ b/demos/logo_demo/hardware.inc @@ -26,6 +26,14 @@ PTRIG = $C070 ;; BASIC ROUTINES NORMAL = $F273 +BKGND0 = $F3F4 ; clear current page to A +HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y) +HPLOT0 = $F457 ; plot at (Y,X), (A) +COLOR_SHIFT = $F47E +HLINRL = $F530 ; (X,A),(Y) +HGLIN = $F53A ; line to (X,A),(Y) +COLORTBL = $F6F6 + ;; MONITOR ROUTINES diff --git a/demos/logo_demo/music.s b/demos/logo_demo/music.s index 5e0924b6..f5c8172b 100644 --- a/demos/logo_demo/music.s +++ b/demos/logo_demo/music.s @@ -58,6 +58,7 @@ mockingboard_not_found: .include "nozp.inc" .include "decompress_fast_v2.s" +.include "myst_vgi.s" PT3_LOC = $1000 diff --git a/demos/logo_demo/myst_vgi.s b/demos/logo_demo/myst_vgi.s new file mode 100644 index 00000000..f96222d5 --- /dev/null +++ b/demos/logo_demo/myst_vgi.s @@ -0,0 +1,84 @@ +; VGI Myst for LOGO demo + +;.include "zp.inc" +;.include "hardware.inc" + +VGI_BUFFER = $F0 +VGI_TYPE = $F0 +P0 = $F1 +P1 = $F2 +P2 = $F3 +P3 = $F4 +P4 = $F5 +P5 = $F6 +P6 = $F7 +VGIL = $F8 +VGIH = $F9 + +TEMP0 = $FA +TEMP1 = $FB +TEMP2 = $FC +TEMP3 = $FD +TEMP4 = $FE +TEMP5 = $FF + + +vgi_myst: + + ; swap in ROM + + ; READ_ROM_NO_WRITE + bit $C08A + + ; save ZP + ldx #$FF +save_loop: + lda $0,X + sta vgi_save,X + dex + bne save_loop + + jsr vgi_make_tables + + lda #$20 + sta $E6 ; setup page1 + + ; get pointer to image data + + ; Rocket + + lda #rocket_data + sta VGIH + + jsr play_vgi + + ; restore ZP + + ldx #$FF +restore_loop: + lda vgi_save,X + sta $00,X + + dex + bne restore_loop + + + ; restore settings + + ; READ_RAM1_WRITE_RAM1 + + bit $C08B + bit $C08B + + + rts + + +.include "vgi_common.s" + +.include "rocket.data" + +vgi_save = $a00 + diff --git a/demos/logo_demo/rocket.data b/demos/logo_demo/rocket.data new file mode 100644 index 00000000..b49a4de5 --- /dev/null +++ b/demos/logo_demo/rocket.data @@ -0,0 +1,130 @@ +rocket_data: +.byte $16,$16,$00,$7A,$8C,$45 +.byte $16,$16,$8C,$7A,$8B,$45 +.byte $16,$15,$EF,$AB,$28,$14 +.byte $77,$14,$E4,$A2,$E2,$F5,$AB +.byte $77,$14,$E4,$A2,$E0,$F4,$B9 +.byte $77,$14,$E8,$BF,$E0,$F4,$B8 +.byte $77,$14,$FF,$A5,$F5,$FF,$AB +.byte $77,$14,$FF,$B2,$F5,$FF,$AB +.byte $16,$44,$FF,$AA,$18,$08 +.byte $16,$44,$FF,$A3,$0F,$0F +.byte $67,$08,$56,$7C,$6B,$43,$22 +.byte $35,$07,$61,$79,$04 +.byte $35,$07,$B4,$79,$04 +.byte $16,$77,$63,$77,$4C,$08 +.byte $16,$44,$67,$72,$4B,$07 +.byte $87,$04,$5F,$78,$73,$78,$66 +.byte $87,$04,$B9,$78,$73,$78,$AF +.byte $16,$00,$66,$80,$0E,$3F +.byte $16,$00,$9C,$7E,$0D,$41 +.byte $16,$00,$B3,$7E,$0F,$41 +.byte $16,$33,$59,$89,$04,$09 +.byte $16,$33,$BA,$8B,$04,$08 +.byte $44,$05,$04,$5E +.byte $53,$1A,$5E +.byte $87,$04,$19,$5E,$54,$69,$2B +.byte $87,$05,$E9,$67,$67,$72,$B3 +.byte $35,$04,$D9,$57,$20 +.byte $35,$07,$F7,$57,$19 +.byte $16,$44,$E7,$3B,$20,$05 +.byte $87,$04,$FF,$3A,$36,$3A,$DE +.byte $16,$44,$E6,$6C,$13,$0C +.byte $16,$44,$F0,$6F,$26,$04 +.byte $16,$44,$DC,$73,$2B,$05 +.byte $16,$55,$2C,$54,$BE,$11 +.byte $87,$05,$2C,$54,$4D,$54,$45 +.byte $87,$05,$EA,$58,$4B,$58,$B6 +.byte $16,$55,$4B,$4C,$73,$08 +.byte $87,$07,$DF,$54,$54,$58,$EA +.byte $16,$55,$2C,$65,$8D,$05 +.byte $87,$05,$E4,$65,$65,$6B,$BB +.byte $87,$05,$2C,$6A,$6A,$71,$4A +.byte $16,$55,$4A,$6A,$6F,$07 +.byte $87,$05,$4A,$71,$71,$64,$66 +.byte $87,$05,$B5,$71,$71,$64,$AD +.byte $16,$54,$63,$71,$4A,$04 +.byte $16,$44,$EA,$58,$05,$0D +.byte $87,$04,$AD,$54,$4F,$58,$A3 +.byte $87,$04,$DB,$58,$53,$57,$D2 +.byte $67,$CC,$43,$50,$07,$1E,$B3 +.byte $67,$CC,$46,$4C,$05,$04,$B3 +.byte $67,$CC,$46,$6A,$05,$08,$B3 +.byte $67,$CC,$B7,$4C,$07,$24,$B3 +.byte $44,$04,$96,$50 +.byte $53,$73,$50 +.byte $53,$73,$6C +.byte $53,$78,$6F +.byte $53,$89,$6F +.byte $44,$07,$8A,$51 +.byte $53,$8A,$6D +.byte $44,$04,$8B,$60 +.byte $53,$A8,$61 +.byte $44,$04,$8B,$64 +.byte $53,$A5,$64 +.byte $16,$66,$94,$74,$0A,$08 +.byte $16,$77,$93,$65,$0B,$10 +.byte $16,$51,$96,$67,$05,$0A +.byte $77,$16,$9A,$5F,$94,$9E,$65 +.byte $44,$02,$97,$61 +.byte $53,$9B,$61 +.byte $77,$11,$80,$81,$65,$6D,$BF +.byte $77,$13,$81,$81,$6D,$81,$BF +.byte $16,$33,$81,$81,$16,$3E +.byte $77,$11,$99,$81,$AA,$B3,$BF +.byte $77,$13,$98,$81,$98,$AA,$BF +.byte $44,$00,$98,$81 +.byte $53,$AA,$BF +.byte $44,$00,$81,$81 +.byte $53,$6D,$BF +.byte $44,$00,$7F,$73 +.byte $53,$80,$85 +.byte $44,$03,$7F,$73 +.byte $53,$7A,$81 +.byte $44,$02,$7B,$7E +.byte $53,$7B,$93 +.byte $44,$03,$78,$80 +.byte $53,$74,$90 +.byte $53,$6D,$9A +.byte $53,$63,$9E +.byte $16,$22,$61,$A4,$03,$1B +.byte $35,$02,$62,$A1,$04 +.byte $44,$00,$99,$75 +.byte $53,$98,$84 +.byte $44,$03,$99,$76 +.byte $53,$9D,$81 +.byte $44,$02,$9E,$7E +.byte $53,$9D,$8D +.byte $44,$03,$9E,$7F +.byte $53,$A2,$8E +.byte $53,$A8,$9A +.byte $53,$B2,$A0 +.byte $16,$22,$B1,$A4,$04,$1B +.byte $35,$02,$B3,$A1,$04 +.byte $16,$66,$AE,$58,$05,$26 +.byte $16,$66,$AE,$49,$05,$07 +.byte $44,$06,$B1,$5A +.byte $53,$B1,$4A +.byte $44,$00,$81,$BF +.byte $53,$90,$BB +.byte $44,$00,$8B,$BC +.byte $53,$84,$B4 +.byte $53,$82,$AA +.byte $53,$81,$9D +.byte $53,$86,$95 +.byte $53,$8B,$8F +.byte $53,$87,$8A +.byte $53,$86,$84 +.byte $53,$8A,$7E +.byte $53,$83,$7F +.byte $44,$00,$7E,$91 +.byte $53,$8F,$8E +.byte $44,$86,$17,$36 +.byte $53,$EE,$41 +.byte $53,$B1,$4A +.byte $53,$AA,$52 +.byte $53,$AD,$55 +.byte $53,$BD,$58 +.byte $53,$D1,$56 +.byte $FF + diff --git a/demos/logo_demo/rocket.vgi b/demos/logo_demo/rocket.vgi new file mode 100644 index 00000000..ab96b913 --- /dev/null +++ b/demos/logo_demo/rocket.vgi @@ -0,0 +1,146 @@ +; Rocket from Myst +;CLS 255 ; white background +RECT 1 6 0 122 140 191 ; ocean left +RECT 1 6 140 122 279 191 ; ocean right +; rock +RECT 1 5 239 171 279 191 ; green/orange rock +VTRI 4 228 162 226 245 171 ; black edge +VTRI 4 228 162 224 244 185 ; black edge +VTRI 4 232 191 224 244 184 ; upside down +VTRI 4 255 165 245 255 171 ; black right edge +VTRI 4 255 178 245 255 171 ; black right edge +RECT 4 4 255 170 279 178 ; rock shade +RECT 4 4 255 163 270 178 ; rock shade +; base +DRECT 0x8 0x22 86 124 193 191 ; green brick dock +FCIRC 7 97 121 4 ; left platform +FCIRC 7 180 121 4 ; right platform +RECT 7 7 99 119 175 127 ; platform +RECT 4 4 103 114 178 121 ; shady platform +HTRI 4 95 120 115 120 102 ; left shady plat +HTRI 4 185 120 115 120 175 ; right shady plat +RECT 0 0 102 128 116 191 ; left shade +RECT 0 0 156 126 169 191 ; center shade +RECT 0 0 179 126 194 191 ; right shade +RECT 3 3 89 137 93 146 ; left light +RECT 3 3 186 139 190 147 ; right light +; spaceship +POINT 5 4 94 ; nosepipe +LINETO 26 94 ; +HTRI 4 25 94 84 105 43 ; noscone +; draw deeper Z body +HTRI 5 233 103 103 114 179 ; behind bottom fin +; draw tails +FCIRC 4 217 87 32 ; tails +FCIRC 7 247 87 25 ; tails cutout +RECT 4 4 231 59 263 64 ; top fin +HTRI 4 255 58 54 58 222 +RECT 4 4 230 108 249 120 ; bottom fin +RECT 4 4 240 111 278 115 ; bottom fin +RECT 4 4 220 115 263 120 ; bottom fin +; draw body +RECT 5 5 44 84 234 101 ; body +HTRI 5 44 84 77 84 69 ; left top +HTRI 5 234 88 75 88 182 ; right top +RECT 5 5 75 76 190 84 ; center top +HTRI 7 223 84 84 88 234 ; right cutout +RECT 5 5 44 101 185 106 ; next strip down +HTRI 5 228 101 101 107 187 ; over bottom fin +HTRI 5 44 106 106 113 74 ; left under +RECT 5 5 74 106 185 113 ; next layer +HTRI 5 74 113 113 100 102 ; next left +HTRI 5 181 113 113 100 173 ; next right +RECT 5 4 99 113 173 117 ; next layer +; decorations +RECT 4 4 234 88 239 101 ; nozzle +HTRI 4 173 84 79 88 163 ; weird scoop +HTRI 4 219 88 83 87 210 ; another scoop +DRECT 0xcc 0xb3 67 80 74 110 ; left stripe +DRECT 0xcc 0xb3 70 76 75 80 ; left stripe +DRECT 0xcc 0xb3 70 106 75 114 ; left stripe +DRECT 0xcc 0xb3 183 76 190 112 ; right stripe +; door +POINT 4 150 80 +LINETO 115 80 +LINETO 115 108 +LINETO 120 111 +LINETO 137 111 +POINT 7 138 81 +LINETO 138 109 +; door lines +POINT 4 139 96 +LINETO 168 97 +POINT 4 139 100 +LINETO 165 100 +; marker switch +RECT 6 6 148 116 158 124 ; base +RECT 7 7 147 101 158 117 ; border +RECT 5 1 150 103 155 113 ; woodgrain +VTRI 6 154 95 148 158 101 ; top +POINT 2 151 97 ; handle +LINETO 155 97 +; walkway +VTRI 1 128 129 101 109 191 ; left path green +VTRI 3 129 129 109 129 191 ; left path white +RECT 3 3 129 129 151 191 ; center path +VTRI 1 153 129 170 179 191 ; right path green +VTRI 3 152 129 152 170 191 ; right path white +POINT 0 152 129 ; right gap +LINETO 170 191 ; right gap +POINT 0 129 129 ; left gap +LINETO 109 191 ; left gap +; left railing +POINT 0 127 115 ; far left pole +LINETO 128 133 +POINT 3 127 115 ; far left rope +LINETO 122 129 +POINT 2 123 126 ; center left pole +LINETO 123 147 +POINT 3 120 128 ; center left rope +LINETO 116 144 +LINETO 109 154 +LINETO 99 158 +RECT 2 2 97 164 100 191 ; near pole +FCIRC 2 98 161 4 ; near pole circle +; right railing +POINT 0 153 117 ; far right pole +LINETO 152 132 +POINT 3 153 118 ; far right rope +LINETO 157 129 +POINT 2 158 126 ; center right pole +LINETO 157 141 +POINT 3 158 127 ; center right rope +LINETO 162 142 +LINETO 168 154 +LINETO 178 160 +RECT 2 2 177 164 181 191 ; near pole +FCIRC 2 179 161 4 ; near pole circle +; wire pole +RECT 6 6 174 88 179 126 ; pole +RECT 6 6 174 73 179 80 ; insulator +POINT 6 177 90 ; thinner pole +LINETO 177 74 ; to top +; shadow +POINT 0 129 191 +LINETO 144 187 +POINT 0 139 188 +LINETO 132 180 +LINETO 130 170 +LINETO 129 157 +LINETO 134 149 +LINETO 139 143 +LINETO 135 138 +LINETO 134 132 +LINETO 138 126 +LINETO 131 127 +POINT 0 126 145 +LINETO 143 142 +; power wire +POINT 6 279 54 ; from off screen +LINETO 238 65 +LINETO 177 74 +LINETO 170 82 +LINETO 173 85 +LINETO 189 88 +LINETO 209 86 +END diff --git a/demos/logo_demo/vgi_circles.s b/demos/logo_demo/vgi_circles.s new file mode 100644 index 00000000..ffc038bc --- /dev/null +++ b/demos/logo_demo/vgi_circles.s @@ -0,0 +1,303 @@ +; VGI_Circles + + +XX = TEMP0 +MINUSXX = TEMP1 +YY = TEMP2 +MINUSYY = TEMP3 +D = TEMP4 +COUNT = TEMP5 + + ;======================== + ; VGI circle + ;======================== + + VGI_CCOLOR = P0 + VGI_CX = P1 + VGI_CY = P2 + VGI_CR = P3 + +vgi_circle: + ldx VGI_CCOLOR + lda COLORTBL,X + sta HGR_COLOR + + ;=============================== + ; draw circle + ;=============================== + ; draw circle at (CX,CY) of radius R + ; signed 8-bit math so problems if R > 64? + + ; XX=0 YY=R + ; D=3-2*R + ; GOTO6 + + lda #0 + sta XX + + lda VGI_CR + sta YY + + lda #3 + sec + sbc VGI_CR + sbc VGI_CR + sta D + + jmp do_plots + +circle_loop: + ; X=X+1 + + inc XX + + ; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10 + lda D + bmi else + + dec YY + + lda XX + sec + sbc YY + asl + asl + clc + adc D + adc #10 + jmp store_D + +else: + ; ELSE D=D+4*X+6 + lda XX + asl + asl + clc + adc D + adc #6 +store_D: + sta D + +do_plots: + ; setup constants + + lda XX + eor #$FF + sta MINUSXX + inc MINUSXX + + lda YY + eor #$FF + sta MINUSYY + inc MINUSYY + + ; HPLOT CX+X,CY+Y + ; HPLOT CX-X,CY+Y + ; HPLOT CX+X,CY-Y + ; HPLOT CX-X,CY-Y + ; HPLOT CX+Y,CY+X + ; HPLOT CX-Y,CY+X + ; HPLOT CX+Y,CY-X + ; HPLOT CX-Y,CY-X + + ; calc X co-ord + + lda #7 + sta COUNT +pos_loop: + lda COUNT + and #$4 + lsr + tay + + lda COUNT + lsr + bcc xnoc + iny +xnoc: + lda VGI_CX + clc + adc XX,Y + tax + + ; calc y co-ord + + lda COUNT + lsr + eor #$2 + tay + + lda VGI_CY + clc + adc XX,Y + + ldy #0 + + jsr HPLOT0 ; plot at (Y,X), (A) + + dec COUNT + bpl pos_loop + + + ; IFY>=XTHEN4 + lda YY + cmp XX + bcs circle_loop + + jmp vgi_loop + + + + + ;======================== + ; VGI circle + ;======================== + ; VGI_CCOLOR = P0 + ; VGI_CX = P1 + ; VGI_CY = P2 + ; VGI_CR = P3 + +vgi_filled_circle: + ldx VGI_CCOLOR + lda COLORTBL,X + sta HGR_COLOR + + ;=============================== + ; draw filled circle + ;=============================== + ; draw filled circle at (CX,CY) of radius R + ; signed 8-bit math so problems if R > 64? + + + ; XX=0 YY=R + ; D=3-2*R + ; GOTO6 + + lda #0 + sta XX + + lda VGI_CR + sta YY + + lda #3 + sec + sbc VGI_CR + sbc VGI_CR + sta D + + jmp do_filled_plots + +filled_circle_loop: + ; X=X+1 + + inc XX + + ; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10 + lda D + bmi filled_else + + dec YY + + lda XX + sec + sbc YY + asl + asl + clc + adc D + adc #10 + jmp store_filled_D + +filled_else: + ; ELSE D=D+4*X+6 + lda XX + asl + asl + clc + adc D + adc #6 +store_filled_D: + sta D + +do_filled_plots: + ; setup constants + + lda XX + eor #$FF + sta MINUSXX + inc MINUSXX + + lda YY + eor #$FF + sta MINUSYY + inc MINUSYY + + ; HPLOT CX+X,CY+Y + ; HPLOT CX-X,CY+Y + ; HPLOT CX+X,CY-Y + ; HPLOT CX-X,CY-Y + ; HPLOT CX+Y,CY+X + ; HPLOT CX-Y,CY+X + ; HPLOT CX+Y,CY-X + ; HPLOT CX-Y,CY-X + + + + + lda #3 + sta COUNT +filled_pos_loop: + + ; calc left side + + ; calc X co-ord + + lda COUNT + ora #$1 + eor #$2 + tay + lda VGI_CX + clc + adc XX,Y + tax + + ; calc y co-ord + + ldy COUNT + lda VGI_CY + clc + adc XX,Y + + ldy #0 + +; pha ; save Y value for later + + jsr HPLOT0 ; plot at (Y,X), (A) + + + ; calc right side + lda COUNT + and #$2 + eor #$2 + tay + lda XX,Y + asl + + ldy #0 + ldx #0 + + jsr HLINRL ; plot relative (X,A), (Y) + ; so in our case (0,XX*2),0 + + + + dec COUNT + bpl filled_pos_loop + + + ; IFY>=XTHEN4 + lda YY + cmp XX + bcs filled_circle_loop + + jmp vgi_loop diff --git a/demos/logo_demo/vgi_clearscreen.s b/demos/logo_demo/vgi_clearscreen.s new file mode 100644 index 00000000..600712c1 --- /dev/null +++ b/demos/logo_demo/vgi_clearscreen.s @@ -0,0 +1,7 @@ + +vgi_clearscreen: + +; lda P0 +; jsr BKGND0 + +; jmp vgi_loop ; return diff --git a/demos/logo_demo/vgi_common.s b/demos/logo_demo/vgi_common.s new file mode 100644 index 00000000..1de53856 --- /dev/null +++ b/demos/logo_demo/vgi_common.s @@ -0,0 +1,72 @@ +; VGI library + +VGI_MAXLEN = 7 + + ;================================== + ; play_vgi + ;================================== +play_vgi: + +vgi_loop: + + ldy #0 +data_smc: + lda (VGIL),Y + sta VGI_BUFFER,Y + iny + cpy #VGI_MAXLEN + bne data_smc + + lda VGI_TYPE + and #$f + + clc + adc VGIL + sta VGIL + bcc no_oflo + inc VGIH +no_oflo: + + lda VGI_TYPE + lsr + lsr + lsr + lsr + + ; look up action in jump table + asl + tax + lda vgi_rts_table+1,X + pha + lda vgi_rts_table,X + pha + rts ; "jump" to subroutine + +vgi_rts_table: + .word vgi_clearscreen-1 ; 0 = clearscreen + .word vgi_simple_rectangle-1 ; 1 = simple rectangle + .word vgi_circle-1 ; 2 = plain circle + .word vgi_filled_circle-1 ; 3 = filled circle + .word vgi_point-1 ; 4 = dot + .word vgi_lineto-1 ; 5 = line to + .word vgi_dithered_rectangle-1 ; 6 = dithered rectangle + .word vgi_vertical_triangle-1 ; 7 = vertical triangle + .word vgi_horizontal_triangle-1 ; 8 = horizontal triangle + .word vgi_vstripe_rectangle-1 ; 9 = vstripe rectangle + .word vgi_line-1 ;10 = line + .word vgi_line_far-1 ;11 = line far + .word all_done-1 + .word all_done-1 + .word all_done-1 + .word all_done-1 ; 15 = done + +all_done: + rts + + +.include "vgi_clearscreen.s" +.include "vgi_circles.s" +.include "vgi_rectangle.s" +.include "vgi_lines.s" +.include "vgi_triangles.s" + diff --git a/demos/logo_demo/vgi_lines.s b/demos/logo_demo/vgi_lines.s new file mode 100644 index 00000000..4417becd --- /dev/null +++ b/demos/logo_demo/vgi_lines.s @@ -0,0 +1,95 @@ +; VGI Lines + + ;======================== + ; VGI point + ;======================== +vgi_point: + jsr vgi_point_common + jmp vgi_loop + + + ;======================== + ; VGI point common + ;======================== + + VGI_PCOLOR = P0 ; if high bit set, then PX=PX+256 + VGI_PX = P1 + VGI_PY = P2 + +vgi_point_common: + ldy #0 + + lda VGI_PCOLOR + bpl vgi_point_color + iny +vgi_point_color: + and #$7f + tax + lda COLORTBL,X + sta HGR_COLOR + + ldx VGI_PX + lda VGI_PY + + jsr HPLOT0 ; plot at (Y,X), (A) + + rts + + + + + ;======================== + ; VGI line to + ;======================== + VGI_LX = P0 + VGI_LY = P1 + +vgi_lineto: + ldx #0 + ldy VGI_LY + lda VGI_LX + + jsr HGLIN ; line to (X,A),(Y) + + jmp vgi_loop + + + ;======================== + ; VGI LINE + ;======================== +; VGI_LX = P0 +; VGI_LY = P1 + VGI_LX2 = P3 + VGI_LY2 = P4 + +vgi_line: + jsr vgi_point_common + + ldx #0 + ldy VGI_LY2 + lda VGI_LX2 + + jsr HGLIN ; line to (X,A),(Y) + + jmp vgi_loop + + ;======================== + ; VGI LINE FAR + ;======================== + ; assume second x-coord is > 256 +; VGI_LX = P0 +; VGI_LY = P1 +; VGI_LX2 = P3 +; VGI_LY2 = P4 + +vgi_line_far: + jsr vgi_point_common + + ldx #1 + ldy VGI_LY2 + lda VGI_LX2 + + jsr HGLIN ; line to (X,A),(Y) + + jmp vgi_loop + diff --git a/demos/logo_demo/vgi_rectangle.s b/demos/logo_demo/vgi_rectangle.s new file mode 100644 index 00000000..89006912 --- /dev/null +++ b/demos/logo_demo/vgi_rectangle.s @@ -0,0 +1,462 @@ +; VGI Rectangle + +; VGI Rectangle test + +COLOR_MODE = TEMP0 +OTHER_MASK = TEMP1 +XRUN = TEMP2 + +div7_table = $800 +mod7_table = $900 + +USE_FAST = 1 + + + +.if (USE_FAST=0) + + ; slow + ;================================= + ; Simple Rectangle + ;================================= + VGI_RCOLOR = P0 + VGI_RX1 = P1 + VGI_RY1 = P2 + VGI_RXRUN = P3 + VGI_RYRUN = P4 + +vgi_simple_rectangle: + +simple_rectangle_loop: + + lda VGI_RCOLOR + + asl ; nibble swap by david galloway + adc #$80 + rol + asl + adc #$80 + rol + + sta VGI_RCOLOR + + and #$f + tax + + lda COLORTBL,X + sta HGR_COLOR + + ldx VGI_RX1 ; X1 into X + lda VGI_RY1 ; Y1 into A + ldy #0 ; always 0 + jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y) + + + lda VGI_RXRUN ; XRUN into A + ldx #0 ; always 0 + ldy #0 ; relative Y is 0 + jsr HLINRL ; (X,A),(Y) + + inc VGI_RY1 + dec VGI_RYRUN + bne simple_rectangle_loop + + jmp vgi_loop + + + + ;================================= + ; Dithered Rectangle + ;================================= +; VGI_RCOLOR = P0 +; VGI_RX1 = P1 +; VGI_RY1 = P2 +; VGI_RXRUN = P3 +; VGI_RYRUN = P4 + VGI_RCOLOR2 = P5 + +vgi_dithered_rectangle: + +dithered_rectangle_loop: + lda COUNT + and #$1 + beq even_color +odd_color: + lda VGI_RCOLOR + jmp save_color +even_color: + lda VGI_RCOLOR2 +save_color: + sta HGR_COLOR + + inc COUNT + + ldx VGI_RX1 ; X1 into X + lda VGI_RY1 ; Y1 into A + ldy #0 ; always 0 + jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y) + + + lda VGI_RXRUN ; XRUN into A + ldx #0 ; always 0 + ldy #0 ; relative Y is 0 + jsr HLINRL ; (X,A),(Y) + + inc VGI_RY1 + dec VGI_RYRUN + bne dithered_rectangle_loop + + jmp vgi_loop + + + +.else + + + + + ; FAST + ;================================= + ; Simple Rectangle + ;================================= + VGI_RCOLOR = P0 + VGI_RX1 = P1 + VGI_RY1 = P2 + VGI_RXRUN = P3 + VGI_RYRUN = P4 + VGI_RCOLOR2 = P5 ; only for dither + + ;================================== + ; VGI Simple Rectangle + ;================================== + +vgi_simple_rectangle: + lda #0 + sta COLOR_MODE + +simple_rectangle_loop: + + lda COLOR_MODE + beq simple_colors + bmi striped_colors + bpl handle_dither + + +simple_colors: + + lda VGI_RCOLOR + + asl ; nibble swap by david galloway + adc #$80 + rol + asl + adc #$80 + rol + + sta VGI_RCOLOR + + and #$f + tax + + lda COLORTBL,X + sta HGR_COLOR + jmp done_colors + +handle_dither: + + lda COUNT + and #$1 + beq deven_color +dodd_color: + lda VGI_RCOLOR + jmp dsave_color +deven_color: + lda VGI_RCOLOR2 +dsave_color: + sta HGR_COLOR + + inc COUNT + jmp done_colors +striped_colors: + + ; don't need to do anything here? + +done_colors: + + ; get ROW into (GBASL) + + ldx VGI_RX1 ; X1 into X + lda VGI_RY1 ; Y1 into A + ldy #0 ; always 0 + jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y) + + ; Y is already the RX1/7 + + ; adjust color if in striped mode + lda COLOR_MODE + bpl not_striped + + jsr swap_colors + +not_striped: + + ; copy the XRUN + + lda VGI_RXRUN + sta XRUN + + inc XRUN ; needed because we compare with beq/bne + + + ; check if narrow corner case where begin and end same block + ; if RX%7 + XRUN < 8 + + ldx VGI_RX1 + lda mod7_table,X + clc + adc XRUN + cmp #8 + bcs not_corner + +corner: + ; want to use MASK of left_mask, MOD7 and 7-XRUN + + lda mod7_table,X + tax + + lda (GBASL),Y + eor HGR_BITS + and left_masks,X + ldx XRUN + and right_masks,X + eor (GBASL),Y + sta (GBASL),Y + + jmp done_row ; that's all + +not_corner: + + ; see if not starting on boundary + ldx VGI_RX1 + lda mod7_table,X + beq draw_run + + ; handle not full left border + + tax + lda (GBASL),Y + eor HGR_BITS + and left_masks,X + eor (GBASL),Y + sta (GBASL),Y + + iny ; move to next + + ; adjust RUN length by 7- mod7 + txa ; load mod7 + eor #$ff + sec + adc #7 + eor #$ff + sec + adc XRUN + sta XRUN + +; lda HGR_BITS ; cycle colors for next +; jsr COLOR_SHIFT + + jsr swap_colors + +;no_shift: + + ; draw common +draw_run: + lda XRUN + cmp #7 + bcc draw_right ; blt + + lda HGR_BITS ; get color + sta (GBASL),Y ; store out +; jsr COLOR_SHIFT ; shift colors + + iny ; move to next block + + jsr swap_colors + + lda XRUN ; take 7 off the run + sec + sbc #7 + sta XRUN + + jmp draw_run + + ; draw rightmost +draw_right: + + beq done_row + +; lda HGR_BITS +; jsr COLOR_SHIFT + + ; see if not starting on boundary + ldx XRUN + tax + + lda (GBASL),Y + eor HGR_BITS + and right_masks,X + eor (GBASL),Y + sta (GBASL),Y + +done_row: + + inc VGI_RY1 + dec VGI_RYRUN + ;bne simple_rectangle_loop + beq done_done + jmp simple_rectangle_loop + +done_done: + jmp vgi_loop + + + + ;========================== + ; swap colors + ;========================== +swap_colors: + + lda COLOR_MODE + bmi swap_colors_striped + + lda HGR_BITS ; get color + jsr COLOR_SHIFT ; shift colors + + rts + +swap_colors_striped: + + tya + and #1 + bne swap_odd + + lda VGI_RCOLOR + jmp swap_done + +swap_odd: + lda VGI_RCOLOR2 +swap_done: + sta HGR_BITS + + rts + + + + + + + + + ;================================= + ; Dithered Rectangle + ;================================= +; VGI_RCOLOR = P0 +; VGI_RX1 = P1 +; VGI_RY1 = P2 +; VGI_RXRUN = P3 +; VGI_RYRUN = P4 +; VGI_RCOLOR2 = P5 + +vgi_dithered_rectangle: + lda #1 + sta COLOR_MODE + + lda #0 + sta COUNT + + jmp simple_rectangle_loop + + + ;================================= + ; Vertical Striped Rectangle + ;================================= +; VGI_RCOLOR = P0 +; VGI_RX1 = P1 +; VGI_RY1 = P2 +; VGI_RXRUN = P3 +; VGI_RYRUN = P4 +; VGI_RCOLOR2 = P5 + +vgi_vstripe_rectangle: + lda #128 + sta COLOR_MODE + + lda #0 + sta COUNT + + jmp simple_rectangle_loop + + +.endif + + + + + + + ;===================== + ; make /7 %7 tables + ;===================== + +vgi_init: + +vgi_make_tables: + + ldy #0 + lda #0 + ldx #0 +div7_loop: + sta div7_table,Y + + inx + cpx #7 + bne div7_not7 + + clc + adc #1 + ldx #0 +div7_not7: + iny + bne div7_loop + + + ldy #0 + lda #0 +mod7_loop: + sta mod7_table,Y + clc + adc #1 + cmp #7 + bne mod7_not7 + lda #0 +mod7_not7: + iny + bne mod7_loop + + rts + +left_masks: + .byte $FF,$FE,$FC,$F8, $F0,$E0,$C0 + +right_masks: + .byte $81,$83,$87, $8F,$9F,$BF,$FF + + + + + + + + + + diff --git a/demos/logo_demo/vgi_triangles.s b/demos/logo_demo/vgi_triangles.s new file mode 100644 index 00000000..259b8b6f --- /dev/null +++ b/demos/logo_demo/vgi_triangles.s @@ -0,0 +1,96 @@ +; VGI Triangles + +SKIP = TEMP0 + + ;======================== + ; VGI vertical triangle + ;======================== + + VGI_TCOLOR = P0 + VGI_VX = P1 + VGI_VY = P2 + VGI_TXL = P3 + VGI_TXR = P4 + VGI_TYB = P5 + +vgi_vertical_triangle: + lda VGI_TCOLOR + lsr + lsr + lsr + lsr + sta SKIP + + lda VGI_TCOLOR + and #$f + tax + lda COLORTBL,X + sta HGR_COLOR + +vtri_loop: + ldy #0 + ldx VGI_VX + lda VGI_VY + + jsr HPLOT0 ; plot at (Y,X), (A) + + + ldx #0 + ldy VGI_TYB + lda VGI_TXL + + jsr HGLIN ; line to (X,A),(Y) + + lda VGI_TXL + clc + adc SKIP + sta VGI_TXL +; inc VGI_TXL +; lda VGI_TXL + cmp VGI_TXR + bcc vtri_loop + +done_vtri: + jmp vgi_loop ; bra + + + + ;======================== + ; VGI horizontal triangle + ;======================== + +; VGI_TCOLOR = P0 +; VGI_VX = P1 +; VGI_VY = P2 + VGI_THYT = P3 + VGI_THYB = P4 + VGI_THXR = P5 + +vgi_horizontal_triangle: + + ldx VGI_TCOLOR + lda COLORTBL,X + sta HGR_COLOR + +htri_loop: + ldy #0 + ldx VGI_VX + lda VGI_VY + + jsr HPLOT0 ; plot at (Y,X), (A) + + + ldx #0 + ldy VGI_THYT + lda VGI_THXR + + jsr HGLIN ; line to (X,A),(Y) + + inc VGI_THYT + lda VGI_THYT + cmp VGI_THYB + bcc htri_loop + +done_htri: + jmp vgi_loop + diff --git a/demos/logo_demo/zp.inc b/demos/logo_demo/zp.inc index 0acb0414..8e748bb8 100644 --- a/demos/logo_demo/zp.inc +++ b/demos/logo_demo/zp.inc @@ -12,8 +12,8 @@ MB_ADDR_H = $0D ; only used for title screen... -TEMP = $FA -TEMPY = $FB +;TEMP = $FA +;TEMPY = $FB ;INL = $FC ;INH = $FD ;OUTL = $FE @@ -27,3 +27,35 @@ GBASL = $26 GBASH = $27 BASL = $28 BASH = $29 + +HGR_COLOR = $E4 + +.if 0 +VGI_BUFFER = $F0 +VGI_TYPE = $F0 +P0 = $F1 +P1 = $F2 +P2 = $F3 +P3 = $F4 +P4 = $F5 +P5 = $F6 +P6 = $F7 +VGIL = $F8 +VGIH = $F9 + +OUTL = $FC +OUTH = $FD + +COLOR1 = $FE +COLOR2 = $FF + +TEMP0 = $10 +TEMP1 = $11 +TEMP2 = $12 +TEMP3 = $13 +TEMP4 = $14 +TEMP5 = $15 +.endif + +HGR_BITS = $1C +