我“模拟”任天堂Gameboy标志演示在Amstrad CPC模拟器(WinApe)在模式视频1,编码在组装的Z80。
当我“油漆”只有标志(直到第25行和其他行在主循环中的评论),它画得很好,但当我试图创建动画(油漆,擦除,油漆等),出现一些“垃圾”像素以前没有画。
这是我的代码:
;; testlogo.asm
;;
.cls equ &BC14 ;; Clear screen
org &4000
run &4000
;;
call cls
ld hl, #c020 ;; initial position of video
ld a,#05 ;; times logo down
call loop1 ;; call main loop
jr $
;;
loop1:
ld bc,logo ;; initial position of logo
;; bc remains until logo
;; is fully painted
ld e,#08
call loop_paint
ld de, #c050
add hl,de
;; the second 8 row group pixels
ld e,#08
call loop_paint
ld de,#c050
add hl,de
;; wait until 'down' logo
ld b,#cc
call wait
ld de, #ff60 ;; recover hl position
;; to 'erase' upward logo
add hl,de
ld e,#08
call loop_erase1 ;; call to 'erase' pixels
;; from logo
;; (it could be optimized in one calling)
ld de, #c050
add hl,de
ld e,#08
call loop_erase1
ld de, #c050
add hl,de
dec a
jr nz, loop1
ret
;;
loop_paint:
ld d,#0b
call loop_logo ;; call to paint logo
push bc ;; save bc in stack
;; for using adding in bc
ld bc,#07f5 ;; 800 for next row (minus) 0b last column
add hl,bc
pop bc
dec e
jr nz, loop_paint
ret
;;
loop_logo: ;; finally 'paints' logo
;; in memory video
push af ;; save 'a' register
;; because is used
;; as counter in main loop
ld a, (bc)
ld (hl), a
pop af
inc l
inc c
dec d
jr nz,loop_logo
ret
;;
loop_erase1: ;; row by row in mode 1 video
ld d,#0b
call loop_erase2
ld bc,#07f5 ;;800 next row - 0b last column
add hl,bc
dec e
jr nz,loop_erase1
ret
;;
loop_erase2: ;; column by column in mode 1 video
ld (hl), #00
inc l
dec d
jr nz,loop_erase2
ret
;;
logo:
db #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
db #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
db #00, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #88, #00
db #33, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #EE, #00
db #33, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #E6, #00
db #FC, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #F1, #88
db #FD, #F5, #FB, #F5, #FE, #FF, #F3, #F3, #FB, #FD, #88
db #FD, #F9, #FB, #FD, #F0, #F8, #F4, #FA, #F1, #F1, #88
db #FD, #F1, #FA, #FD, #F6, #FF, #F4, #FB, #F9, #F1, #88
db #FD, #F9, #FA, #F5, #F2, #F1, #F4, #FA, #F1, #F1, #88
db #FD, #F5, #FA, #F5, #FE, #FF, #F3, #F2, #F1, #F1, #88
db #FC, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #F1, #88
db #33, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #F0, #E6, #00
db #33, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #EE, #00
db #00, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #FF, #88, #00
db #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
ret
;;
wait:
halt
dec b
jr nz,wait
ret
下面是模拟器窗口中的结果:
最后一行标识必须为红色,且不包含其他颜色,标识为红色和黄色。
1条答案
按热度按时间bweufnob1#
当我将指针增量从8位更改为16位时,问题得到解决:“inc l”代表“inc hl”,“inc c”代表“inc bc”。
感谢“忙碌的蜜蜂”用户。