-
Notifications
You must be signed in to change notification settings - Fork 0
/
UTIL.S
93 lines (80 loc) · 2.27 KB
/
UTIL.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
processor 6502
; UTIL.S GENERAL UTILITY ROUTINES
; MOVE A CREATURE HORIZONTALLY
; INPUT: A - CURRENT HORIZONTAL POS, Y - DIRECTION CREATURE FACING
; OUTPUT:A - NEW HORIZONTAL POS
HPOSADJ CLC
ADC PHPOSTAB,Y
RTS
; MOVE A CREATURE VERTICALLY
; INPUT: A - CURRENT VERTICAL POS, Y - DIRECTION CREATURE FACING
; X - CURRENT VERTICAL OFFSET
; OUTPUT:A - NEW VERTICAL POS
VPOSADJ CPY #DUP
BEQ VPAUP
CPY #DDOWN
BNE VPAOUT
CLC ;MOVE IT DOWN
ADC DNADJUST,X
RTS
VPAUP SEC ;MOVE IT UP
SBC UPADJUST,X
VPAOUT RTS
; BODY OF MACRO PFILL
PFILLIT LDY #0
PFLOOP STA (TEMP0),Y
DEY
BNE PFLOOP
INC TEMP1
DEX
BNE PFLOOP
RTS
; BODY OF MACRO PLOAD
PLOADIT LDY #0
PLLOOP LDA (TEMP2),Y
STA (TEMP0),Y
DEY
BNE PLLOOP
INC TEMP1
INC TEMP3
DEX
BNE PLLOOP
RTS
; CONVERT HORIZONTAL BIT COUNT TO COLUMN
HTOC SEC
SBC #LEFTSIDE ;SHIFT ORIGIN
LSR A
LSR A ;AND SCALE
RTS
; CONVERT COLUMN TO HORIZONTAL BIT COUNT
CTOH ASL A ;SCALE
ASL A
CLC
ADC #LEFTSIDE ;SHIFT ORIGIN
RTS
; CONVERT VERTICAL BIT TO ZONE AND OFFSET
; OUTPUT: ZONE IN Y, OFFSET IN A
; USES Y!
VTOZO LDY #$00 ;BRUTE FORCE - SLOW
VTZAGAIN CMP #$06 ;SEE IF ANYTHING TO DO
BCS VTZDOIT
RTS
VTZDOIT INY ;INCREMENT ZONE
SEC ;SUBTRACT 6
SBC #$06
JMP VTZAGAIN
; CONVERT ZONE TO VERTICAL BIT
; USES Y!
ZTOV TAY
LDA #$00
ZVLOOP CPY #$00
BEQ ZVOUT
CLC
ADC #$06
DEY
JMP ZVLOOP
ZVOUT RTS
; TABLES FOR EASY MOVEMENT
PHPOSTAB DB $01,$00,$FF,$00
DNADJUST DB $02,$01,$01,$02,$01,$01
UPADJUST DB $01,$01,$02,$01,$01,$02