graphics: add xdraw category

This commit is contained in:
Vince Weaver 2021-05-03 14:24:28 -04:00
parent ef3c30c42f
commit 865dfbcb99
8 changed files with 630 additions and 0 deletions

View File

@ -0,0 +1,74 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
EMPTYDISK = ../../../empty_disk/empty.dsk
LINKERSCRIPTS = ../../../linker_scripts
all: xdraw.dsk
xdraw.dsk: HELLO TINY_XDRAW TINY_COOL TINY_LINES TINY_CENTER NYAN
cp $(EMPTYDISK) xdraw.dsk
$(DOS33) -y xdraw.dsk SAVE A HELLO
$(DOS33) -y xdraw.dsk BSAVE -a 0xE7 TINY_XDRAW
$(DOS33) -y xdraw.dsk BSAVE -a 0xE7 TINY_COOL
$(DOS33) -y xdraw.dsk BSAVE -a 0xE7 TINY_LINES
$(DOS33) -y xdraw.dsk BSAVE -a 0xE7 TINY_CENTER
$(DOS33) -y xdraw.dsk BSAVE -a 0xC00 NYAN
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
TINY_XDRAW: tiny_xdraw.o
ld65 -o TINY_XDRAW tiny_xdraw.o -C ./apple2_e7_zp.inc
tiny_xdraw.o: tiny_xdraw.s
ca65 -o tiny_xdraw.o tiny_xdraw.s -l tiny_xdraw.lst
###
TINY_COOL: tiny_cool.o
ld65 -o TINY_COOL tiny_cool.o -C ./apple2_e7_zp.inc
tiny_cool.o: tiny_cool.s
ca65 -o tiny_cool.o tiny_cool.s -l tiny_cool.lst
###
TINY_CENTER: tiny_center.o
ld65 -o TINY_CENTER tiny_center.o -C ./apple2_e7_zp.inc
tiny_center.o: tiny_center.s
ca65 -o tiny_center.o tiny_center.s -l tiny_center.lst
###
TINY_LINES: tiny_lines.o
ld65 -o TINY_LINES tiny_lines.o -C ./apple2_e7_zp.inc
tiny_lines.o: tiny_lines.s
ca65 -o tiny_lines.o tiny_lines.s -l tiny_lines.lst
###
NYAN: nyan.o
ld65 -o NYAN nyan.o -C $(LINKERSCRIPTS)/apple2_c00.inc
nyan.o: nyan.s
ca65 -o nyan.o nyan.s -l nyan.lst
####
clean:
rm -f *~ *.o *.lst HELLO TINY_COOL TINY_XDRAW TINY_LINES TINY_CENTER NYAN

View File

@ -0,0 +1 @@
20 PRINT CHR$(4)"CATALOG"

113
graphics/hgr/xdraw/nyan.s Normal file
View File

@ -0,0 +1,113 @@
; Finish this
; also, lo-res possible?
; zero page
HGR_DX = $D0 ; HGLIN
HGR_DX2 = $D1 ; HGLIN
HGR_DY = $D2 ; HGLIN
HGR_QUADRANT = $D3
HGR_E = $D4
HGR_E2 = $D5
HGR_X = $E0
HGR_X2 = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
HGR_PAGE = $E6
HGR_SCALE = $E7
HGR_SHAPE_TABLE = $E8
HGR_SHAPE_TABLE2= $E9
HGR_COLLISIONS = $EA
HGR_ROTATION = $F9
; Soft Switches
PAGE0 = $C054
PAGE1 = $C055
; ROM calls
HGR2 = $F3D8
HGR = $F3E2
HPOSN = $F411
XDRAW0 = $F65D
XDRAW1 = $F661
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
RESTORE = $FF3F
nyan:
;6ROT=0:SCALE=5:P=49236:HGR:HGR2:GOSUB8:Q=1:POKE230,32:GOSUB8
jsr HGR
jsr HGR2 ; Hi-res, full screen ; 3
; Y=0, A=0 after this call
lda #5 ; scale=5
sta HGR_SCALE
jsr eight
; Q=1 (draw to next page)
; move hgr page from $40 to $20
lda #$20
sta HGR_PAGE
jsr eight
seven:
bit PAGE0
lda #100
jsr WAIT
bit PAGE1
lda #100
jsr WAIT
jmp seven
eight:
; A and Y are 0 here.
; X is left behind by the boot process?
ldy #0
ldx #134
lda #102
jsr HPOSN ; set screen position to X= (y,x) Y=(a)
; saves X,Y,A to zero page
; after Y= orig X/7
; A and X are ??
ldx #<nyan_shape ; point to bottom byte of shape address
ldy #>nyan_shape ; point to top byte of shape address
; ROT in A
; this will be 0 2nd time through loop, arbitrary otherwise
lda #0 ; ROT=0
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
; Z flag set on exit
; Y varies
;8C=5:Y=80:XDRAW1AT134,102+Q*2:GOSUB9:C=1:GOSUB9:C=6:GOSUB9:C=2
nine:
;9HCOLOR=C:FORZ=YTOY+5:FORX=0TO13:Q=NOTQ:HPLOTX*8,Z+QTOX*8+7,Z+Q:NEXTX,Z:Y=Z
rts
nyan_shape:
.byte "$,.,6>???$$--5",0

View File

@ -0,0 +1,79 @@
; Tiny Tiny
; zero page locations
HGR_SHAPE = $1A
HGR_SHAPE2 = $1B
HGR_BITS = $1C
GBASL = $27
GBASH = $28
A5H = $45
XREG = $46
YREG = $47
; C0-CF should be clear
; D0-DF?? D0-D5 = HGR scratch?
HGR_DX = $D0 ; HGLIN
HGR_DX2 = $D1 ; HGLIN
HGR_DY = $D2 ; HGLIN
HGR_QUADRANT = $D3
HGR_E = $D4
HGR_E2 = $D5
HGR_X = $E0
HGR_X2 = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
HGR_SCALE = $E7
HGR_SHAPE_TABLE = $E8
HGR_SHAPE_TABLE2= $E9
HGR_COLLISIONS = $EA
HGR_ROTATION = $F9
FRAME = $FC
XPOS = $FD
YPOS = $FF
; ROM calls
HGR2 = $F3D8
HPOSN = $F411
XDRAW0 = $F65D
XDRAW1 = $F661
RESTORE = $FF3F
.zeropage
.globalzp rot_smc
tiny_tiny:
jsr HGR2 ; Hi-res, full screen ; 3
; Y=0, A=0 after this call
lda #40
sta HGR_SCALE
tiny_loop:
inc rot_smc+1
; setup X and Y co-ords
ldy #0 ; Y always 0
ldx #140
lda #96
jsr HPOSN ; X= (y,x) Y=(a)
; saves Y/X/A to HGR_Y, HGR_X, HGR_X+1
; after, Y = X/7
; after, y = $14 = 20, always
; A=FF, X=F9
ldx #<shape_table ; point to our shape
ldy #0
rot_smc:
lda #0 ; ROT=0
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
; Z flag set on exit
beq tiny_loop ; bra
shape_table:
.byte $2D,0 ; shape data
; RT RT is 00 101 101 = 2D

View File

@ -0,0 +1,49 @@
; Tiny Tiny
; zero page locations
HGR_SHAPE = $1A
A5H = $45
XREG = $46
YREG = $47
HGR_SCALE = $E7
HGR_ROTATION = $F9
FRAME = $FC
XPOS = $FD
YPOS = $FF
; ROM calls
HGR2 = $F3D8
HPOSN = $F411
XDRAW0 = $F65D
RESTORE = $FF3F
.zeropage
tiny_tiny:
jsr HGR2 ; Hi-res graphics, no text at bottom
; Y=0, A=0 after this call
lda #1
sta HGR_SCALE
tiny_loop:
; setup X and Y co-ords
ldy #0 ; Y always 0
ldx #140
lda #96
jsr HPOSN ; X= (y,x) Y=(a)
ldx #<shape_table ; point to our shape
rot_smc:
lda #0 ; ROT=0
tay ; ldy #>shape_table
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
inc rot_smc+1
jmp tiny_loop
shape_table:
.byte 18,0 ; shape data

View File

@ -0,0 +1,133 @@
; Tiny Tiny
; zero page locations
HGR_SHAPE = $1A
HGR_SHAPE2 = $1B
HGR_BITS = $1C
GBASL = $26
GBASH = $27
A5H = $45
XREG = $46
YREG = $47
; C0-CF should be clear
; D0-DF?? D0-D5 = HGR scratch?
HGR_DX = $D0 ; HGLIN
HGR_DX2 = $D1 ; HGLIN
HGR_DY = $D2 ; HGLIN
HGR_QUADRANT = $D3
HGR_E = $D4
HGR_E2 = $D5
HGR_X = $E0
HGR_X2 = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
HGR_SCALE = $E7
HGR_SHAPE_TABLE = $E8
HGR_SHAPE_TABLE2= $E9
HGR_COLLISIONS = $EA
HGR_ROTATION = $F9
FRAME = $FC
XPOS = $FD
YPOS = $FF
; ROM calls
HGR2 = $F3D8
HGR = $F3E2
HPOSN = $F411
XDRAW0 = $F65D
XDRAW1 = $F661
RESTORE = $FF3F
.zeropage
.globalzp rot_smc
tiny_tiny:
jsr HGR2 ; Hi-res, full screen ; 3
; Y=0, A=0 after this call
; lda #$10
; stx HGR_SCALE ; loading so JSR ($20) is at scale ($E7)
; ldy #0 ; Y already 0
; ldx #140
; lda #96
txa
jsr HPOSN ; X= (y,x) Y=(a)
; sta GBASL
; sta GBASH
; lda #40
; sta HGR_SCALE
; lda #$46
; sta GBASH
; lda #$A8
; sta GBASL
; setup X and Y co-ords
; ldy #0 ; Y always 0
; ldx #140
; lda #96
; jsr HPOSN ; X= (y,x) Y=(a)
; saves Y/X/A to HGR_Y, HGR_X, HGR_X+1
; after, Y = X/7
; after, y = $14 = 20, always
; A=FF, X=F9
; GBASL = 46A8
tiny_loop:
inc rot_smc+1
ldx #<shape_table ; point to our shape
shape_table:
ldy #0
rot_smc:
lda #0 ; ROT=0
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
; Z flag set on exit
; Y varies
beq tiny_loop ; bra
;shape_table:
; .byte $A8,0 ; shape data
; 22 00 = $D
; 30 would work
; NUP=0 UP=4
; NRT=1 RT=5
; NDN=2 DN=6
; NLT=3 LT=7
; INVALID 00 000 000 = 00
; NRT NUP 00 000 001 = 01
; NDN NUP 00 000 010 = 02
; NLT NUP 00 000 011 = 03
; UP NUP 00 000 100 = 04
; LT NUP 00 000 111 = 07
; NDN NRT 00 001 010 = 0A
; RT NRT 00 001 101 = 0D
; NUP NLT 00 011 000 = 18
; LT NLT 00 011 111 = 1F
; NUP UP 00 100 000 = 20
; UP NDN 00 100 010 = 22 ****
; NUP RT 00 101 000 = 28
; UP RT 00 101 100 = 2C
; RT RT is 00 101 101 = 2D
; LT RT is 00 101 111 = 2F ****
; NUP DN 00 110 000 = 30 ****
; DN DN 00 110 110 = 36
; NUP LT 00 111 000 = 38
; is 10 100 000 = UP NUP

View File

@ -0,0 +1,70 @@
; Tiny Tiny
; zero page locations
HGR_SHAPE = $1A
HGR_BITS = $1C
GBASL = $27
GBASH = $28
A5H = $45
XREG = $46
YREG = $47
; C0-CF should be clear
; D0-DF?? D0-D5 = HGR scratch?
HGR_DX = $D0 ; HGLIN
HGR_DX2 = $D1 ; HGLIN
HGR_DY = $D2 ; HGLIN
HGR_QUADRANT = $D3
HGR_E = $D4
HGR_E2 = $D5
HGR_X = $E0
HGR_X2 = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
HGR_SCALE = $E7
HGR_SHAPE = $E8
HGR_SHAPE2 = $E9
HGR_COLLISIONS = $EA
HGR_ROTATION = $F9
FRAME = $FC
XPOS = $FD
YPOS = $FF
; ROM calls
HGR2 = $F3D8
HPOSN = $F411
XDRAW0 = $F65D
RESTORE = $FF3F
.zeropage
tiny_tiny:
jsr HGR2 ; Hi-res, full screen ; 3
; Y=0, A=0 after this call
; lda #40
; sta HGR_SCALE
tiny_loop:
; setup X and Y co-ords
ldy #0 ; Y always 0
ldx #140
lda #96
jsr HPOSN ; X= (y,x) Y=(a)
; saves Y/X/A to HGR_Y, HGR_X, HGR_X+1
; ldx #<shape_table ; point to our shape
; ldy #0
rot_smc:
lda #0 ; ROT=0
jsr XDRAW1 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
inc rot_smc+1
jmp tiny_loop
shape_table:
.byte $2D,0 ; shape data
; RT RT is 00 101 101 = 2D

View File

@ -0,0 +1,111 @@
; Tiny Xdraw
; repeatedly draws an image from an Apple II shape table
; can arbitrarily point to any memory location as a source of these
; some look amazing but depend on random machine state
; to be deterministic you should probably stick to
; $E7-$F0 (the program itself)
; $D000-$FFFF (the ROMs)
; shapetables are a bit complicated to explain here, but they are a
; series of bytes ending with a $00
; (note if you point to a zero, it will be interpreted as an
; action not an end)
; each byte specifies up to 3 actions, DRAW + UP DOWN LEFT RIGHT or
; NODRAW + UP DOWN LEFT RIGHT
; It is vector scaling with SCALE we hardcode to $20 and rotation
; which gets set to 0 after the first iteration, (which is
; why the first shape has arbitrary rotation and gets left)
; we are xdrawing so it will XOR with the current pixels on the screen
; NUP=0 UP=4 zz yyy xxx , does xxx yyy zz
; NRT=1 RT=5
; NDN=2 DN=6
; NLT=3 LT=7
; zero page locations
HGR_SHAPE = $1A
HGR_SHAPE2 = $1B
HGR_BITS = $1C
GBASL = $26
GBASH = $27
A5H = $45
XREG = $46
YREG = $47
; C0-CF should be clear
; D0-DF?? D0-D5 = HGR scratch?
HGR_DX = $D0 ; HGLIN
HGR_DX2 = $D1 ; HGLIN
HGR_DY = $D2 ; HGLIN
HGR_QUADRANT = $D3
HGR_E = $D4
HGR_E2 = $D5
HGR_X = $E0
HGR_X2 = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
HGR_SCALE = $E7
HGR_SHAPE_TABLE = $E8
HGR_SHAPE_TABLE2= $E9
HGR_COLLISIONS = $EA
HGR_ROTATION = $F9
FRAME = $FC
XPOS = $FD
YPOS = $FF
; ROM calls
HGR2 = $F3D8
HGR = $F3E2
HPOSN = $F411
XDRAW0 = $F65D
XDRAW1 = $F661
RESTORE = $FF3F
.zeropage
.globalzp rot_smc
tiny_xdraw:
jsr HGR2 ; Hi-res, full screen ; 3
; Y=0, A=0 after this call
; we load at $E7 which is HGR_SCALE, so HGR_SCALE gets
; the value of the above JSR instruction ($20)
; A and Y are 0 here.
; X is left behind by the boot process?
txa
jsr HPOSN ; set screen position to X= (y,x) Y=(a)
; saves X,Y,A to zero page
; after Y= orig X/7
; A and X are ??
tiny_loop:
; values for shape table
; Y X
; 00 E7 = neat
; 00 EB = OK
; 00 EF = good
; F0 01 = cool, let's go with it
ldx #$01 ; point to bottom byte of shape address
ldy #$f0 ; point to top byte of shape address
; ROT in A
; this will be 0 2nd time through loop, arbitrary otherwise
; lda #0 ; ROT=0
jsr XDRAW0 ; XDRAW 1 AT X,Y
; Both A and X are 0 at exit
; Z flag set on exit
; Y varies
beq tiny_loop ; bra