pas mal pour tester les programmes assembleur
ou le compilateur C

il fonctionne en plus ... je vous laisse chercher
Modérateur : Politburo



Code : Tout sélectionner
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned char COLOR;
#define WHITE 0
#define BLACK 1
#define REVERSE 2
#define NULL 0
enum Key
{
SHIFT = 0x80,
DOWN = 0x1f,
UP = 0x20,
LEFT = 0x21,
RIGHT = 0x22,
SPACE = 0x1e,
CLS = 0x50,
};
void printNum(BYTE x, BYTE y, WORD value);
/*********************************
•¶Žš—ñŠÖŒW
*********************************/
/*
* strlen(BYTE *string)
* •¶Žš—ñ‚Ì’·‚³‚𑪂é
*/
BYTE strlen(BYTE *string)
{
BYTE i;
for(i=0; string[i]; ++i);
return i;
}
/*********************************
•\ަŠÖŒW
*********************************/
/*
* printChr(BYTE x, BYTE y, char c)
* Žw’肵‚½À•W‚É•¶Žš—ñ‚ð•\ަ
*/
void printChr(BYTE x, BYTE y, char c)
{
_asm
; de <- loc
ld e,4(ix)
ld d,5(ix)
; a <- _c
ld a,6(ix)
; •¶Žš‚ð•\ަ‚·‚郋[ƒ`ƒ“
call #0xbe62
_endasm;
}
/*
* printStr(BYTE x, BYTE y, char *string)
* Žw’肵‚½À•W‚É•¶Žš—ñ‚ð•\ަ
*/
void printStr_asm(BYTE len, WORD loc, char *str);
void printStr(BYTE x, BYTE y, char *string)
{
printStr_asm(strlen(string),x+y*256 ,string);
}
void printStr_asm(BYTE len, WORD loc, char *str)
{
_asm
; b <- len
ld b,4(ix)
; de <- loc
ld e,5(ix)
ld d,6(ix)
; hl <- str‚Ìpointer
ld l,7(ix)
ld h,8(ix)
; •¶Žš‚ð•\ަ‚·‚郋[ƒ`ƒ“
call #0xbff1
_endasm;
}
/*
* printGra(BYTE x, BYTE y, char *gpattern)
* Žw’肵‚½À•W‚ɃOƒ‰ƒtƒBƒbƒN‚ð•\ަ
*/
void printGra_asm(BYTE len, WORD loc, char *gpattern);
void printGra(BYTE x, BYTE y, char *gpattern, int size)
{
printGra_asm(size, x+y*256, gpattern);
}
void printGra_asm(BYTE len, WORD loc, char *gpattern)
{
_asm
; b <- len
ld b,4(ix)
; de <- loc
ld e,5(ix)
ld d,6(ix)
; hl <- gpattern‚Ìpointer
ld l,7(ix)
ld h,8(ix)
; •¶Žš‚ð•\ަ‚·‚郋[ƒ`ƒ“
call #0xbfd0
_endasm;
}
/*
* printNum(BYTE x, BYTE y, WORD value)
* Žw’肵‚½‰ÓЂɔ’l‚ð•\ަ(0~65535‚Ì®”)
*/
void printNum(BYTE x, BYTE y, WORD value)
{
char str[6];
int i;
for(i=4; i>=0; i--) {
str[i] = '0' + value % 10;
value /= 10;
}
str[5] = NULL;
printStr(x,y,str);
}
/*
* printHex(BYTE x, BYTE y, WORD value)
* Žw’肵‚½‰ÓŠ‚É16i”‚ð•\ަ(0x0000~0xffff‚Ì®”)
*/
void printHex(BYTE x, BYTE y, WORD value)
{
char str[5];
int i;
for(i=3; i>=0; i--) {
str[i] = value % 16;
str[i] += str[i] < 10 ? '0' : 'A' - 10;
value /= 16;
}
str[4] = NULL;
printStr(x,y,str);
}
/*
* clearScreen()
* ‰æ–Ê‚ðÁ‹Ž‚·‚é
*/
void clearScreen()
{
_asm
ld a,#0x20
ld b,#144
ld de,#0
call #0xbfee
_endasm;
}
/*
* pointSet(WORD x, WORD y, COLOR c)
* ƒhƒbƒg‚ð•\ަ‚·‚é
* ref: http://orange.kakiko.com/cosmopatrol/more/motto7.html
*/
void pointSet_asm(BYTE x, BYTE y, BYTE c);
void pointSet(WORD x, WORD y, COLOR c)
{
pointSet_asm((BYTE)x,(BYTE)y,c);
}
void pointSet_asm(BYTE x, BYTE y, BYTE c)
{
_asm
push af
; ‹@Ží”»•Ê
ld a,(#0x93cd)
cp #0xe5
jr nz,_s3
ld a,#0xcd
jr _s4
_s3:
ld a,#0xcb
_s4:
ld (_n2+1),a
pop af
; hl <- 00 _x
; de <- 00 _y
ld l,4(ix)
ld e,5(ix)
ld h,#0
ld d,h
; a <- _c
ld a,6(ix)
ld (#0x7967),hl
ld (#0x7969),de
ld iy,#0xffff
ld (#0x777d),iy
ld (#0x777f),a
call _n2
jr _n3
; ‹@Ží”»•ʂő‚«Š·‚í‚éB
_n2:
call #0x93cd
.db #0x0d
.dw #0xc595
ret
_n3:
_endasm;
}
/*********************************
“ü—ÍŠÖŒW
*********************************/
/*
* inkeyWait()
* ƒL[“ü—͑҂¿
*/
enum Key inkeyWait()
{
_asm
call #0x0bcfd
; –ß‚è’l hl <- a
ld l,a
ld h,#0
_endasm;
}
/*
* inkey()
* ƒŠƒAƒ‹ƒ^ƒCƒ€ƒL[“ü—Í
*/
enum Key inkey()
{
_asm
call #0x0be53
; –ß‚è’l hl <- a
ld l,a
ld h,#0
_endasm;
}
/*********************************
‚»‚Ì‘¼
*********************************/
/*
* wait(int t)
* ƒEƒFƒCƒg‚·‚é
*/
void wait(WORD t)
{
while(t--);
}

Code : Tout sélectionner
#include "/z80/lib/lib.c"
void main(void)
{
long bou;
int key;
clearScreen();
printStr(2,2,"DEBUT");
do
{
key=inkey();
printNum(2,3,key);
}
while(key!=30);
printStr(2,4,"FIN");
}













l'émulateur n'est pas de moi mais trouvé sur un site japonaiszpalm a écrit :Whaouu! je suis impressionné !!!


Tout à fait, n'importe quel être humain peut manger un oeuf.Chris a écrit :Et c'est utilisable par le commun des mortels comme moi ???

oui sans problème je peux faire un package avec toute la config déjà faite pour l'émulateur si beaucoup d'incantationsChris a écrit :Et c'est utilisable par le commun des mortels comme moi ???

Par le pouvoir de l'Oeuf je t'implore de nous faire un package.charognard a écrit :oui sans problème je peux faire un package avec toute la config déjà faite pour l'émulateur si beaucoup d'incantations![]()
