autumn: comment code

This commit is contained in:
Vince Weaver 2020-05-06 12:43:07 -04:00
parent 275a8a622e
commit 02fe35ae9e

View File

@ -1,12 +1,7 @@
; Autumn, based on the code in Hellmood's Autumn ; Autumn, based on the code in Hellmood's Autumn
; by deater (Vince Weaver) <vince@deater.net> ; by deater (Vince Weaver) <vince@deater.net>
; Zero Page ; Zero Page Addresses
BASL = $28
BASH = $29
H2 = $2C
;COLOR = $30
XCOORDL = $F0 XCOORDL = $F0
XCOORDH = $F1 XCOORDH = $F1
@ -19,155 +14,194 @@ EBP4 = $F7
COLORL = $F8 COLORL = $F8
COLORH = $F9 COLORH = $F9
TEMP = $FA
TEMPY = $FB
FRAME = $FC
TEMPX = $FD
; Soft Switches ; Soft Switches
KEYPRESS= $C000 KEYPRESS= $C000
KEYRESET= $C010 KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines ; ROM routines
; Some of these are in the Applesoft ROMs so need at least an Apple II+
; or later to run
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved) TEXT = $FB36 ; Set text mode
SETCOL = $F864 HGR2 = $F3D8 ; Set full-screen hi-res mode using page 2 ($4000)
TEXT = $FB36 ;; Set text mode ; 280x192 6-colors
BASCALC = $FBC1 HPLOT0 = $F457 ; Plot point, (Y,X) = Horizontal, (A=Vertical)
SETGR = $FB40 HCOLOR = $F6EC ; Set color in X, must be 0..7
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HLINE = $F819
HGR2 = $F3D8
HPLOT0 = $F457 ; (Y,X) = Horizontal, (A=Vertical)
HCOLOR = $F6EC ; color in x, must be 0..7
autumn: autumn:
;=================== ;===================
; init screen ; init screen ; Instruction Length
jsr HGR2 ; 3 jsr HGR2 ; 3
ldx #0
stx XCOORDL
stx YCOORDL
stx XCOORDH
stx YCOORDH
stx EBP1
stx EBP2
stx EBP3
stx EBP4
stx COLORH
lda #$4f ; init vars to zero. Apple II doesn't clear RAM
sta COLORL ; some of these might not be necessary
; should make this a loop
ldx #0 ; 2
stx XCOORDL ; 2
stx YCOORDL ; 2
stx XCOORDH ; 2
stx YCOORDH ; 2
stx EBP1 ; 2
stx EBP2 ; 2
stx EBP3 ; 2
stx EBP4 ; 2
stx COLORH ; 2
; not necessary? on x86 is probably the
; result of the VESA BIOS call
; lda #$4f
; sta COLORL
autumn_forever: autumn_forever:
clc ; 16-bit shift of color
rol COLORL ; shl %ax ; 2nd is a rotate as asl doesn't shift in cary
rol COLORH asl COLORL ; 2 ; shl %ax
rol COLORH ; 2
ldx XCOORDL ; put old X value to X/Y
ldy XCOORDH ; save old X ; push/pop is 1 byte each but have to get
; value into accumulator first
ldx XCOORDL ; 2
ldy XCOORDH ; 2
sec ; 16-bit subtraction x=x-y
lda XCOORDL ; need to set carry before subtraction on 6502
sbc YCOORDL ; X=X-Y sec ; 1
sta XCOORDL lda XCOORDL ; 2
lda XCOORDH sbc YCOORDL ; 2
sbc YCOORDH sta XCOORDL ; 2
sta XCOORDH lda XCOORDH ; 2
sbc YCOORDH ; 2
sta XCOORDH ; 2
cmp #$80 ; 16-bit arithmatic shift right of X
ror XCOORDH ; asr X ; 6502 has no asr instruction
ror XCOORDL ; cmp #$80 sets carry if high bit set
cmp #$80 ; 2
ror XCOORDH ; 2
ror XCOORDL ; 2
clc ; 16-bit add, y=y+oldx
txa clc ; 1
adc YCOORDL ; y=y+oldx txa ; 1
sta YCOORDL adc YCOORDL ; 2
tya sta YCOORDL ; 2
adc YCOORDH tya ; 2
sta YCOORDH adc YCOORDH ; 2
sta YCOORDH ; 2
cmp #$80 ; 16-bit arithmatic shift right of y-coord
ror YCOORDH ; asr Y cmp #$80 ; 2
ror YCOORDL ror YCOORDH ; 2
ror YCOORDL ; 2
; 32 bit rotate of low bit of Y ; 32 bit rotate of low bit shifted out of Y-coordinate
ror EBP1 ror EBP1 ; 2
ror EBP2 ror EBP2 ; 2
ror EBP3 ror EBP3 ; 2
ror EBP4 ; ror bottom bit of Y through 32 bits ror EBP4 ; 2
bcs label_11f ; branch if carry set
bcs label_11f ; 2
clc ; 16-bit increment of color
lda COLORL ; no need to clear carry as we wouldn't be
adc #1 ; here if it wasn't
sta COLORL inc COLORL ; 2
lda COLORH bne no_oflo ; 2
adc #0 inc COLORH ; 2
sta COLORH no_oflo:
clc ; 16-bit add of X-coord by 0x80
lda XCOORDL ; this keeps the drawing roughly to the 280x192 screen
adc #$80 ; carry should still be clear (inc doesn't set it)
sta XCOORDL ; X+=0x80 lda XCOORDL ; 2
lda XCOORDH adc #$80 ; 2
adc #$0 sta XCOORDL ; 2
sta XCOORDH lda XCOORDH ; 2
adc #$0 ; 2
sta XCOORDH ; 2
sec ; 16-bit negate of Y-coord
lda YCOORDL sec ; 1
eor #$FF lda YCOORDL ; 2
adc #$0 ; Y=-Y eor #$FF ; 2
sta YCOORDL adc #$0 ; 2
lda YCOORDH sta YCOORDL ; 2
eor #$FF lda YCOORDH ; 2
adc #$0 eor #$FF ; 2
sta YCOORDH adc #$0 ; 2
sta YCOORDH ; 2
label_11f: label_11f:
; lda COLOR ; skipping the color manipulation done here by original
; and #$fc
; eor #$12
; sta COLOR
lda YCOORDH ; if ycoord negative, loop
bmi autumn_forever ; if negative, loop lda YCOORDH ; 2
bmi autumn_forever ; 2
; if top bits of xcoord, loop
lda XCOORDH ; 2
and #$f0 ; 2
bne autumn_forever ; 2
lda XCOORDH
and #$f0
bne autumn_forever
put_pixel: put_pixel:
lda COLORL ; get color mapping
and #$7 ; using lookup table for now whil trying to find best
beq black1 lda COLORL ; 2
cmp #$4 and #$7 ; 2
bne not_black2 tay ; 1
lda #$5 ldx color_lookup,Y ; 3 (could be 2 if we had in zero page)
bne not_black2
black1:
lda #$1
not_black2: ; actually set the color
tax jsr HCOLOR ; 3
jsr HCOLOR
ldx XCOORDL ; set up paramaters for HPLOT call
ldy XCOORDH ldx XCOORDL ; 2
lda YCOORDL ldy XCOORDH ; 2
jsr HPLOT0 lda YCOORDL ; 2
jsr HPLOT0 ; 3
jmp autumn_forever ; 3 lda KEYPRESS ; 3 ; see if key pressed
; bpl autumn_forever ; loop if not
bmi exit_to_prompt ; 2 ; jump target too far away
jmp autumn_forever ; 3 ; if we get under 128 bytes
; can use the smaller jump
exit_to_prompt:
jsr TEXT ; 3 ; return to text mode
jmp $3D0 ; 3 ; return to Applesoft prompt
; Apple II Hi-Res Colors
; It's all NTSC artifacting and complex
; There can be color-class at a 3.5 pixel level
; And adjacent on pixels make white, adjacent off make black
; Simplistic summary, you can have these 8 colors (6 unique)
; 0 = Black0
; 1 = Green
; 2 = Purple
; 3 = White0
; 4 = Black1
; 5 = Orange
; 6 = Blue
; 7 = White2
color_lookup:
; my default, colorful palette
; .byte $01,$01,$02,$03, $05,$05,$06,$07
; orange and gren palette
.byte $01,$01,$03,$05, $05,$05,$01,$07
; "Leaves"
; TOP-LEFT ?? CENTER-TOP TOP-RIGHT LEFT ?? CENTER-BOTTOM ??