Писал подобную программу, в которой рисование было сделано не прямоугольниками, а точками, так как эмулятор поддерживал старую версию MOS 1.3
В новой можно набрать команду установки режима, набрав VDU 22 8 и запустить программу
macro CLS
ld a, 12
rst.lil $10
endmacro
.assume adl=1 ; ez80 ADL memory mode
.org $40000 ; load code here
jp start_here ; jump to start of code
.align 64 ; MOS header
.db "MOS",0,1
start_here:
push af ; store all the registers
push bc
push de
push ix
push iy
; ------------------
; This is our actual code
; prepare the screen
; SET_MODE 8 ; mode 8 is 640x480 pixels, 64 colours
; ld a, 22 ; set mode...
; rst.lil $10
; ld a, 8
; rst.lil $10
CLS
ld c,8
ylp:
ld a,10
ld (rxy),a
ld a,18
ld (rcxy),a
ld b,8
xlp:
push bc
; Sending a VDU byte stream
ld hl, VDUdata ; address of string to use
ld bc, endVDUdata - VDUdata ; length of string
rst.lil $18 ; Call the MOS API to send data to VDP
pop bc
ld a,(rc+2)
inc a
ld (rc+2),a
ld a,(rxy)
add a,8
ld (rxy),a
ld a,(rcxy)
add a,8
ld (rcxy),a
djnz xlp
ld a,(rxy+2)
add a,8
ld (rxy+2),a
ld a,(rcxy+2)
add a,8
ld (rcxy+2),a
dec c
jr nz,ylp
ld a, $08 ; code to send to MOS
rst.lil $08 ; get IX pointer to System Variables
WAIT_HERE: ; loop here until we hit ESC key
ld a, (ix + $05) ; get ASCII code of key pressed
cp 27 ; check if 27 (ascii code for ESC)
jp z, EXIT_HERE ; if pressed, jump to exit
jr WAIT_HERE
; ------------------
; This is where we exit the program
EXIT_HERE:
CLS
pop iy ; Pop all registers back from the stack
pop ix
pop de
pop bc
pop af
ld hl,0 ; Load the MOS API return code (0) for no errors.
ret ; Return to MOS
; ------------------
; This is the data we send to VDP
VDUdata:
.db 23, 0, 192, 0 ; set to non-scaled graphics
; FOR A RECTANGLE
rc: .db 18, 0, 0 ; set graphics colour: mode (0), colour
.db 25, 69 ; PLOT: mode (69 is a point in current colour),
rxy: .dw 10,10
.db 25, 101 ; PLOT: mode (101 is a filled rectangle),
rcxy: .dw 18,18
endVDUdata:
; ------------------
; colour data
bright_red: equ 9
green: equ 2
bright_yellow: equ 11
bright_magenta: equ 13
blue: equ 4
white: equ 7
black: equ 0
bright_white: equ 15
ld a, 12
rst.lil $10
endmacro
.assume adl=1 ; ez80 ADL memory mode
.org $40000 ; load code here
jp start_here ; jump to start of code
.align 64 ; MOS header
.db "MOS",0,1
start_here:
push af ; store all the registers
push bc
push de
push ix
push iy
; ------------------
; This is our actual code
; prepare the screen
; SET_MODE 8 ; mode 8 is 640x480 pixels, 64 colours
; ld a, 22 ; set mode...
; rst.lil $10
; ld a, 8
; rst.lil $10
CLS
ld c,8
ylp:
ld a,10
ld (rxy),a
ld a,18
ld (rcxy),a
ld b,8
xlp:
push bc
; Sending a VDU byte stream
ld hl, VDUdata ; address of string to use
ld bc, endVDUdata - VDUdata ; length of string
rst.lil $18 ; Call the MOS API to send data to VDP
pop bc
ld a,(rc+2)
inc a
ld (rc+2),a
ld a,(rxy)
add a,8
ld (rxy),a
ld a,(rcxy)
add a,8
ld (rcxy),a
djnz xlp
ld a,(rxy+2)
add a,8
ld (rxy+2),a
ld a,(rcxy+2)
add a,8
ld (rcxy+2),a
dec c
jr nz,ylp
ld a, $08 ; code to send to MOS
rst.lil $08 ; get IX pointer to System Variables
WAIT_HERE: ; loop here until we hit ESC key
ld a, (ix + $05) ; get ASCII code of key pressed
cp 27 ; check if 27 (ascii code for ESC)
jp z, EXIT_HERE ; if pressed, jump to exit
jr WAIT_HERE
; ------------------
; This is where we exit the program
EXIT_HERE:
CLS
pop iy ; Pop all registers back from the stack
pop ix
pop de
pop bc
pop af
ld hl,0 ; Load the MOS API return code (0) for no errors.
ret ; Return to MOS
; ------------------
; This is the data we send to VDP
VDUdata:
.db 23, 0, 192, 0 ; set to non-scaled graphics
; FOR A RECTANGLE
rc: .db 18, 0, 0 ; set graphics colour: mode (0), colour
.db 25, 69 ; PLOT: mode (69 is a point in current colour),
rxy: .dw 10,10
.db 25, 101 ; PLOT: mode (101 is a filled rectangle),
rcxy: .dw 18,18
endVDUdata:
; ------------------
; colour data
bright_red: equ 9
green: equ 2
bright_yellow: equ 11
bright_magenta: equ 13
blue: equ 4
white: equ 7
black: equ 0
bright_white: equ 15
Комментарии
Отправить комментарий