dos33fsprogs/graphics/hgr/shape_table/gears.s

190 lines
2.9 KiB
ArmAsm
Raw Normal View History

2023-01-25 02:15:11 +00:00
; Rotating Gears
2023-01-25 04:00:15 +00:00
; by Vince `deater` Weaver
2023-01-25 02:15:11 +00:00
; 138 bytes -- original for Apple II bot
; 134 bytes -- only set SCALE once
; 131 bytes -- unecessary var set, change jmp to bra
2023-01-25 04:00:15 +00:00
; 110 bytes -- move draw_scene to a function
2022-10-06 02:20:46 +00:00
; 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
2023-01-25 04:00:15 +00:00
2022-10-10 06:34:32 +00:00
ROTATION = $FA
SMALLER = $FB
2023-01-25 04:00:15 +00:00
CURRENT_ROT = $FF
2022-10-10 06:34:32 +00:00
; Soft Switches
PAGE1 = $C054 ; Page1
PAGE2 = $C055 ; Page2
2022-10-06 02:20:46 +00:00
; ROM calls
HGR2 = $F3D8
HGR = $F3E2
HPOSN = $F411
DRAW0 = $F601
XDRAW0 = $F65D
XDRAW1 = $F661
2022-10-10 06:34:32 +00:00
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
2022-10-06 02:20:46 +00:00
RESTORE = $FF3F
2023-01-25 02:15:11 +00:00
gears:
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
;============================
; scene 1
;============================
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
jsr HGR ; Hi-res, full screen ; 3
2022-10-06 02:20:46 +00:00
; Y=0, A=0 after this call
2022-10-10 06:34:32 +00:00
lda #8
2022-10-06 02:20:46 +00:00
sta HGR_SCALE
2023-01-25 04:00:15 +00:00
lda #1
sta CURRENT_ROT
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
sty SMALLER ; init to 0
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
jsr draw_scene
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
;===================
; scene2
;===================
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
jsr HGR2 ; set to hires PAGE2, full screen
; Y=0, A=0 after
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
lda #<gear2_table ; draw alternate gear
sta which_smc+1
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
jsr draw_scene
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
;===================
2023-01-25 04:00:15 +00:00
; rotate forever
;===================
; just page flipping with a delay
2022-10-10 06:34:32 +00:00
2023-01-25 04:00:15 +00:00
rotate_it:
bit PAGE1
lda #255
jsr WAIT
2022-10-10 06:34:32 +00:00
2023-01-25 04:00:15 +00:00
bit PAGE2
lda #255
jsr WAIT
beq rotate_it ; bra
;=========================
; draw scene
;=========================
; Y must be 0 at entry
draw_scene:
; Y is zero from HGR
2022-10-10 06:34:32 +00:00
ldx #110
lda #10
jsr HPOSN ; set screen position to X= (y,x) Y=(a)
2023-01-25 04:00:15 +00:00
; saves X,Y,A to zero page
; after Y= orig X/7
; A and X are ??
2022-10-10 06:34:32 +00:00
ldy #32
jsr draw_gear
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
ldy #0
ldx #235
lda #100
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 ??
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
inc SMALLER
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
ldy #16
jsr draw_gear
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
dec SMALLER
2022-10-10 06:34:32 +00:00
2023-01-25 04:00:15 +00:00
rts
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
;===============================
;===============================
;===============================
;===============================
draw_gear:
sty ROTATION
gear1_loop:
2022-10-06 02:20:46 +00:00
2023-01-25 04:00:15 +00:00
inc CURRENT_ROT
inc CURRENT_ROT
; inc rot_smc+1
; inc rot_smc+1
2022-10-10 06:34:32 +00:00
lda SMALLER
beq not_smaller
2023-01-25 04:00:15 +00:00
inc CURRENT_ROT
inc CURRENT_ROT
; inc rot_smc+1
; inc rot_smc+1
2022-10-10 06:34:32 +00:00
not_smaller:
which_smc:
ldx #<gear1_table ; point to bottom byte of shape address
ldy #>gear1_table ; point to top byte of shape address
2022-10-06 02:20:46 +00:00
; ROT in A
; this will be 0 2nd time through loop, arbitrary otherwise
2022-10-10 06:34:32 +00:00
rot_smc:
2023-01-25 04:00:15 +00:00
; lda #1 ; ROT=0
lda CURRENT_ROT
2022-10-10 06:34:32 +00:00
jsr XDRAW0 ; XDRAW 1 AT X,Y
2022-10-06 02:20:46 +00:00
; Both A and X are 0 at exit
; Z flag set on exit
; Y varies
2022-10-10 06:34:32 +00:00
dec ROTATION
bne gear1_loop
rts
2022-10-06 02:20:46 +00:00
2022-10-10 06:34:32 +00:00
gear1_table:
2023-01-25 04:00:15 +00:00
.byte $25,$35,$00 ; 37,53,0
2022-10-10 06:34:32 +00:00
gear2_table:
2023-01-25 04:00:15 +00:00
.byte $2c,$2e,$00 ; 44,46,0
2023-01-25 02:15:11 +00:00