更改 Amstrad CPC 464 的 Z80 组件中的文本颜色

问题描述 投票:0回答:1

我正在尝试使用 Z80 处理器的汇编语言编写这个程序,类似于 Amstrad CPC 464 中的游戏“The Typing of The Dead”。

该程序包括,当您在屏幕上看到一串字符(例如黄色的单词)时,您必须完全按照所示输入。如果输入正确,字符串将变为浅蓝色并继续游戏。如果输入错误,字符串将更改为红色连字符并显示“游戏结束”。

我正在使用 Amstrad CPC 464 的固件,例如此链接:

[http://www.cantrell.org.uk/david/tech/cpc/cpc-firmware/firmware.pdf][1]

我有一些代码在屏幕上逐像素绘制字符,但我想使用固件来写入字符。有办法做到这一点吗?

我想使用固件中的视频模式、笔和墨水指令是可能的,但我不太了解如何使用。

这是我逐像素绘制的代码(使用 WinApe):

org &4000
run &4000
readkey equ &BB1E 

;; START PROGRAM
;; cls
call &bc14
;; initial position video mem.     
ld hl, #c000
;; paint char_a_yellow  
ld bc, char_a_yellow 
;; times to follow rows
ld e,#08
call looph
call wait_typing 
jr $
;; END PROGRAM
;;
;; ROUTINES
looph:
  ;; Times to inc l (cols)
  ld d, #02
  ;; save memory video position to stack
  push hl
  call paintpix
  ;; fetch memory video position from stack
  pop hl
  ld a, h
  ;; adds #08 to next row
  add a,#08
  ld h,a
  dec e
jr nz,looph
ret
;;
paintpix:
  ld a, (bc)
  ld (hl),a
  inc l
  inc c
  dec d
  jr nz, paintpix
ret
;;
wait_typing:
  ;; loads in a value of 'a' character
  call &bb18
  ;;and a       ;;Reset  flag carry
  ld b, #61
  sub b
  jp z,typing_right
  ;;and a       ;;Reset flag carry
  ld b, #61
  sub b
  jp nz,typing_wrong
 ret
 ;;
 typing_right:
  ld hl, #c000
  ld bc, char_a_blue 
  ;; times to follow rows
  ld e,#08
  call looph 
 ret
 ;;
 typing_wrong:
  ld hl, #c000
  ld bc, hyphen_red 
  ;; times to follow rows
  ld e,#08
  call looph 
 ret
 ;;
 ;; CHARS BY PIXELS
 ;; left to right, two columns for letter
 ;; row by row 
 char_a_blue:
  db #00, #00
  db #00, #00
  db #07, #08
  db #00, #0c
  db #07, #0c
  db #0c, #0c
  db #07, #06
  db #00, #00
 ret
 ;;
 char_a_yellow:
  db #00, #00
  db #00, #00
  db #70, #80
  db #00, #c0
  db #70, #c0
  db #c0, #c0
  db #70, #60
  db #00, #00
 ret
 ;;
 hyphen_red:
  db #00, #00
  db #00, #00
  db #00, #00
  db #ff, #ff
  db #ff, #ff
  db #00, #00
  db #00, #00
  db #00, #00
 ret
assembly firmware z80
1个回答
0
投票

这是一个简单的解决方案,但固件信息我不太清楚,现在我明白了:

org &4000
run &4000
ld a,2     ; Pen number 2
call &bb90 ; TXT SET PEN (light blue)
ld A,65    ; 65 is ASCII FOR 'A'
call &BB5A ; TXT OUTPUT
jp $
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.