Hi I wrote this code below:
app.c
#include "graphic.h"
#include "cio.h"
//#include
//#include
//#include "sound.h"
void f()
{
color(1,15,6);
screen(2);
pset(10,10);
}
int i=23;
int main() {
void (*f)() = (void (*)())0xc0;
f();
while(1){};
}
and this is my comp.bat:
sdasz80 -o crt0msxrom.o crt0msxrom.s sdcc -mz80 --no-std-crt0 -S -o app.asm app.c graphic.rel cio.rel sdasz80 -o app.o app.asm sdldz80 -nf "link.lnk" hex2bin 8000 linkresult.ihx copy linkresult.bin ROM.ROM
this is graphic.c:
#include "graphic.h"
void color(char fg, char bg, char bd){
_asm
ld hl,#0xf3e9
ld a,4(ix)
ld (hl),a
inc hl
ld a,5(ix)
ld (hl),a
inc hl
ld a,6(ix)
ld (hl),a
call 0x0062 ; --- change color
_endasm;
}
void pset(unsigned char x, unsigned char y)
{
__asm
ld h, 4(ix)
ld l, 5(ix)
call #0x006D ; ---> BIOS call for design a pixel in the screen
__endasm;
}
/*
void paint(unsigned char x, unsigned char y)
{
__asm
{
ld h, 4(ix)
ld l, 5(ix)
call #0x0069 ; ---> BIOS call for color the screen
}
}
char vpeek(int address){
_asm
{
ld l,4(ix)
ld h,5(ix)
call #0x004A ;BIOS call for read a VRAM value
ld h,#0x00
ld l,a
}
}
void vpoke(int address, char value){
_asm
{
ld l,4(ix)
ld h,5(ix)
ld a,6(ix)
call #0x004D ;BIOS call for write a VRAM value
}
}
*/
graphic.h:
//begin of graphic.h void color(char fg, char bg, char bd); void pset(unsigned char x, unsigned char y); void paint(unsigned char x, unsigned char y); char vpeek(int address); void vpoke(int address, char value); //end of graphic.h
this is cio.c:
//module for input and output functions
#include "cio.h"
#include
#include
//function for erase the screen
void cls(void)
{
putchar(0x1b);
putchar(0x45);
}
//function for input one character in the screen
void putchar(char chr)
{
__asm
ld a, 4(ix) ;reg for display the caracter
call 0x00A2 ;BIOS call for display the caracter
__endasm;
}
//function for print a string in the screen
void print(char *string)
{
printf(*string);
}
//function for read one caracter from the keyboard
char inkey(void)
{
__asm
call 0x009F ;BIOS call to read a keyboard caracter
ld h,#0x00
ld l,a ;reg to put a readed caracter
__endasm;
}
//function for put the cursor in the x and y coordinates
void locate(char x,char y)
{
__asm
ld l,4(ix) ;put the coordinate x in the reg l
ld h,5(ix) ;put the coordinata y in the reg h
call 0x00C6 ;BIOS call to move the corsore
__endasm;
}
//function for move only the row position in the screen
void tab(char x)
{
__asm
ld l, 4(ix) ;put the x coordinate in the reg l
call 0x00C6 ;BIOS call for move the cursore
__endasm;
}
//function for input one caracter with eco
void input(char var)
{
var=inkey();
putchar(var);
}
//function for set the mode screen
void screen(unsigned char mode)
{
__asm
ld a,4(ix)
call 0x005F ; --- go to screen mode
call 0x00CC ; --- erase function keys
__endasm;
}
this is cio.h:
//cio.h header file void cls(void); void putchar(char chr); void print(char *string); char inkey(void); void locate(char x,char y); void tab(char x); void input(char var); void screen(unsigned char mode); //end of cio.h
I used the follow file link.lnk:
-- -m -j -x -i linkresult -b _CODE = 0x4000 -b _DATA = 0xc000 -k D:\MSX\SDCC\bin\z80.lib -l z80.lib crt0msxrom.o app.o -e
and I used also the follow file asm crt0msxrom.s:
.module crt0
.globl _main
.globl _romheader
.globl _runrom
.area _CODE
_romheader:
.db 0x41
.db 0x42
.dw _runrom
.dw 0,0,0,0,0,0,0,0
_runrom:
call gsinit
call _main
ret
;this is ordered by first occurence in first file passed to linker?
;note _CODE already has been mentioned in this file.
;; Ordering of segments for the linker.
.area _HOME
.area _CODE
.area _GSINIT
.area _GSFINAL
.area _DATA
.area _BSEG
.area _BSS
.area _HEAP
;sdcc does init global variables from code in _GSINIT areas
.area _GSINIT
gsinit:: ;double colon:: makes label global (asxhtm.html)
.area _GSFINAL
ret
When I compiled and I executed ROM.ROM with bluemsx I didn' t see a pixel in the screen.
Nobody can tell me why please?
Login or register to post comments
