Is it possible to call to Amstrad firmware routines?
The code is compiled with following command:
zcc +cpc -lndos -create-app -o gfx.bin main.c
Code: Select all
#include <conio.h>
#define SCR_SET_MODE 0xBC0E // A=mode (0, 1, 2)
#define GRA_MOVE_ABSOLUTE 0xBBC0 // DE=x, HL=y
#define GRA_LINE_ABSOLUTE 0xBBF6 // DE=x, HL=y
#define GRA_LINE_RELATIVE 0xBBF9 // DE=x, HL=y
#define GRA_SET_ORIGIN 0xBBC9 // DE=x, HL=y
void set_mode(unsigned m) {
#asm
// m parameter SP+2
//ld hl,2
//add hl,sp
//ld a,(hl)
ld a,2 // Forcing mode 2
// in : A = mode (0=160x200x16, 1=320x200x4, 2=640x200x2)
// out: A = mode
call SCR_SET_MODE
#endasm
}
void move(int x, int y) {
#asm
// x parameter SP+4
// y parameter SP+2
ld hl,4
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) // DE = x
ld hl,2
add hl,sp
ld c,(hl)
inc hl
ld b,(hl) // BC = y
ld l,c
ld h,b // HL = BC = y
call GRA_MOVE_ABSOLUTE
#endasm
}
void line(int x, int y) {
#asm
// x parameter SP+4
// y parameter SP+2
ld hl,4
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) // DE = x
ld hl,2
add hl,sp
ld c,(hl)
inc hl
ld b,(hl) // BC = y
ld l,c
ld h,b // HL = BC = y
call GRA_LINE_ABSOLUTE
#endasm
}
void main() {
set_mode(2); // Fails in this call. Video mode is not set
move(0,0);
line(100,100);
while (!kbhit());
}