From b81d473ad3fed559266373cbaaaeb41ca395b353 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 22 Jan 2022 23:23:22 -0500 Subject: [PATCH] xdraw2: initial commit --- demos/l/xdraw2_16/Makefile | 46 ++++++++++++ demos/l/xdraw2_16/apple2_e7_zp.inc | 12 ++++ demos/l/xdraw2_16/file_id.diz | 5 ++ demos/l/xdraw2_16/hello.bas | 8 +++ demos/l/xdraw2_16/xdraw2.s | 111 +++++++++++++++++++++++++++++ 5 files changed, 182 insertions(+) create mode 100644 demos/l/xdraw2_16/Makefile create mode 100644 demos/l/xdraw2_16/apple2_e7_zp.inc create mode 100644 demos/l/xdraw2_16/file_id.diz create mode 100644 demos/l/xdraw2_16/hello.bas create mode 100644 demos/l/xdraw2_16/xdraw2.s diff --git a/demos/l/xdraw2_16/Makefile b/demos/l/xdraw2_16/Makefile new file mode 100644 index 00000000..9e252bb1 --- /dev/null +++ b/demos/l/xdraw2_16/Makefile @@ -0,0 +1,46 @@ +include ../../../Makefile.inc + +DOS33 = ../../../utils/dos33fs-utils/dos33 +TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft +EMPTYDISK = ../../../empty_disk/empty.dsk + +all: xdraw2_16.dsk + +xdraw2_16.dsk: HELLO XDRAW2 + cp $(EMPTYDISK) xdraw2_16.dsk + $(DOS33) -y xdraw2_16.dsk SAVE A HELLO + $(DOS33) -y xdraw2_16.dsk BSAVE -a 0xE7 XDRAW2 + +### + +submit: xdraw16.zip + +xdraw16.zip: XDRAW2 xdraw2.s file_id.diz xdraw2_16.dsk + mkdir -p lovebyte2021_xdraw2_16 + cp XDRAW2 ./lovebyte2021_xdraw2_16 + cp xdraw2.s ./lovebyte2021_xdraw2_16 + cp file_id.diz ./lovebyte2021_xdraw2_16 + cp xdraw2_16.dsk ./lovebyte2021_xdraw2_16 + cp xdraw2_720p.mp4 ./lovebyte2021_xdraw2_16 + zip -r xdraw16.zip lovebyte2021_xdraw2_16 + +#### + + +#### + +HELLO: hello.bas + $(TOKENIZE) < hello.bas > HELLO + +### + +XDRAW2: xdraw2.o + ld65 -o XDRAW2 xdraw2.o -C ./apple2_e7_zp.inc + +xdraw2.o: xdraw2.s + ca65 -o xdraw2.o xdraw2.s -l xdraw2.lst + +#### + +clean: + rm -f *~ *.o *.lst HELLO XDRAW2 *.zip diff --git a/demos/l/xdraw2_16/apple2_e7_zp.inc b/demos/l/xdraw2_16/apple2_e7_zp.inc new file mode 100644 index 00000000..f615f797 --- /dev/null +++ b/demos/l/xdraw2_16/apple2_e7_zp.inc @@ -0,0 +1,12 @@ +MEMORY { + ZP: start = $E7, size = $90, type = rw; + RAM: start = $E7, size = $8E00, file = %O; +} + +SEGMENTS { +#CODE: load = RAM, type = ro; +#RODATA: load = RAM, type = ro; +#DATA: load = RAM, type = rw; +#BSS: load = RAM, type = bss, define = yes; +ZEROPAGE: load = ZP, type = ro; +} diff --git a/demos/l/xdraw2_16/file_id.diz b/demos/l/xdraw2_16/file_id.diz new file mode 100644 index 00000000..2f1997ea --- /dev/null +++ b/demos/l/xdraw2_16/file_id.diz @@ -0,0 +1,5 @@ +Tiny Xdraw +- +Hi-res Xdraw Pattern +16-byte Intro for Apple II, Lovebyte 2021 +by Deater / dSr diff --git a/demos/l/xdraw2_16/hello.bas b/demos/l/xdraw2_16/hello.bas new file mode 100644 index 00000000..6d7cfd2b --- /dev/null +++ b/demos/l/xdraw2_16/hello.bas @@ -0,0 +1,8 @@ +5 HOME +10 PRINT "TINY XDRAW -- A 16 BYTE APPLE II INTRO" +15 PRINT " BY DEATER / DSR" +20 PRINT CHR$(4)"CATALOG" +25 PRINT:PRINT "PRESS ANY KEY TO 'BRUN TINY_XDRAW'" +30 GET A$ +35 PRINT +40 PRINT CHR$(4)"BRUN XDRAW2" diff --git a/demos/l/xdraw2_16/xdraw2.s b/demos/l/xdraw2_16/xdraw2.s new file mode 100644 index 00000000..bd331cbb --- /dev/null +++ b/demos/l/xdraw2_16/xdraw2.s @@ -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? + + tax + 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 #5 ; 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 + + + +