我一直在摆弄ZX Spin模拟器和汇编语言。我曾经在80年代写过BASIC游戏,一直想学习机器代码,但作为一个12岁的孩子太愚蠢了。我已经把这个简单的代码放在一起,它只是创建了一系列组成图像的UDG,并应该将图像打印到屏幕上。我有点卡住了,虽然如何让它使用我的TIT_X_POS和TIT_Y_POS变量,我已经存储和初始化到内存位置。它似乎与DEFB语句中的“_AT”坐标绑定在一起,并且似乎不能向其中传递变量。有人有什么快速提示吗?代码如下:
ORG 30000
_MAIN
CALL SUB_STARTUP
CALL SUB_PRINT_TIT ;Print TIT sprite
RET ;Return to BASIC
_SUBS
SUB_STARTUP
CALL CLS
LD A, 0
LD (TIT_Y_POS), A
LD A, 25
LD (TIT_X_POS), A
RET
SUB_PRINT_TIT
LD HL, TIT_UDGS ;Get location of UDG data.
LD (UDGPOINTER), HL ;Set UDG SYSVAR pointer.
LD A, 2 ;Set output channel 2 (upper screen).
CALL OUTCHAN ;Activate output channel.
LD DE, TIT_STR ;Start of string.
LD BC, TIT_STR_END-TIT_STR ;Length of string.
;;;;;;;;;;STUCK HERE - How do I get it to use TIT_Y_POS and TIT_X_POS instead of the _AT values in DEFB?
CALL PRINTSTRING ;Print string.
RET ; Return from SUB_PRINT_TIT
_SYSVARS
UDGPOINTER EQU 23675 ;UDG pointer.
TIT_X_POS EQU 23700 ;Memory location for X coordinate
TIT_Y_POS EQU 23701 ;Memory location for Y coordinate
_ROM
BORDER EQU 8859 ;Set border color.
CLS EQU 3503 ;Clear screen using attributes in ATTR-P (23693)
OUTCHAN EQU 5633 ;Activate output channel.
PRINTNUMSMALL EQU 6683 ;Print number in BC (9999 max).
PRINTNUMBIG1 EQU 11563 ;(1 of 2) to print number in BC (65535 max).
PRINTNUMBIG2 EQU 11747 ;(2 of 2) to print number in BC (65535 max).
PRINTSTRING EQU 8252 ;Print string (DE start, BC length).
_VALUES
;Store values into memory here.
_STRINGS
TIT_STR ;TIT sprite string.
DEFB _AT, 0, 0, ink, blk, paper, wht, flash, off, bright, off, ua, ub, ue, uf ;TIT - top
DEFB _AT, 1, 0,ink, blk, paper, wht, flash, off, bright, off, uc, ud, ug, uh ;TIT - bottom
TIT_STR_END EQU $ ;Marker for end of string data.
_CODES EQU $
cr equ 13 ;carriage return.
ink equ 16 ;INK control code.
paper equ 17 ;PAPER control code.
flash equ 18 ;FLASH control code.
bright equ 19 ;BRIGHT control code.
inverse equ 20 ;INVERSE control code.
off equ 0 ;OFF control code.
on equ 1 ;ON control code.
_at equ 22 ;AT control code.
_tab equ 23 ;TAB
blk equ 0 ;Blk.
blu equ 1 ;Blue.
red equ 2 ;Red.
mag equ 3 ;Magenta.
grn equ 4 ;Green.
cyn equ 5 ;Cyan.
yel equ 6 ;Yellow.
wht equ 7 ;White.
ua equ 144 ;UDG "A".
ub equ 145 ;UDG "B".
uc equ 146 ;UDG "C".
ud equ 147 ;UDG "D".
ue equ 148 ;UDG "E".
uf equ 149 ;UDG "F".
ug equ 150 ;UDG "G".
uh equ 151 ;UDG "H".
ui equ 152 ;UDG "I".
uj equ 153 ;UDG "J".
uk equ 154 ;UDG "K".
ul equ 155 ;UDG "L".
um equ 156 ;UDG "M".
un equ 157 ;UDG "N".
uo equ 158 ;UDG "O".
up equ 159 ;UDG "P".
uq equ 160 ;UDG "Q".
ur equ 161 ;UDG "R".
us equ 162 ;UDG "S".
ut equ 163 ;UDG "Y".
uu equ 164 ;UDG "U".
_UDGS ;********************************* UDGS ********************************
TIT_UDGS ;UDGs.
; (A,B)Top-left TIT sprite
DEFB 15,18,33,41,41,41,33,17, 255,2,1,0,32,16,16,32
; (C,D)Bot-left TIT sprite
DEFB 18,13,0,0,0,1,0,0, 0,255,64,64,64,255,0,0
; (E,F)Top-right TIT sprite
DEFB 255,32,144,72,72,48,0,0, 255,1,2,2,4,8,16,16
; (G,H)Bot-right TIT sprite
DEFB 0,255,2,2,2,255,0,0, 32,192,0,0,0,128,0,0
字符串
提前感谢。
1条答案
按热度按时间t40tm48m1#
我发现最简单的解决方案是根据DEFB动态调整存储在“TIT_STR”本身中的字节,并在相关位置使用X/Y坐标值:
字符串
x1c 0d1x的数据
因此,只要“TIT_Y_POS”和“TIT_X_POS”在之前被更新,简单地调用“SUB_TIT_PRINT”将总是根据坐标来执行位置。