Last active
April 19, 2025 02:12
-
-
Save fu-sen/e8f9fac72a039b4f93abfd86bd5878a0 to your computer and use it in GitHub Desktop.
Balloons version 2 - PC-G850 siries - z88dk C language https://poke-com.jimdofree.com/z88dk-%E3%81%A7%E3%82%AF%E3%83%AD%E3%82%B9%E9%96%8B%E7%99%BA%E3%81%99%E3%82%8B/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Balloons version 2 | PC-G850 series | z88dk C language | |
Copyright (c) 2025 BALLOON | FU-SEN | |
The MIT License (MIT) - https://mit.balloon.net.eu.org/#2025 | |
zcc +g800 -create-app -bn balloon2 balloon2.c | |
--> MON | |
R | |
G100 | |
*/ | |
void outp(char pnum, char value) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; value | |
ld c,(ix+4) ; pnum | |
out (c),a | |
#endasm | |
} | |
void outpr(char pnum, char value, char size) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld b,(ix+2) ; size | |
ld a,(ix+4) ; value | |
ld c,(ix+6) ; pnum | |
loop_outpr: | |
out (c),a | |
djnz loop_outpr | |
#endasm | |
} | |
void outpir(char pnum, int addr, char size) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld b,(ix+2) ; size | |
ld l,(ix+4) ; addr | |
ld h,(ix+5) | |
ld c,(ix+6) ; pnum | |
otir ; outir | |
#endasm | |
} | |
void getcodei() | |
{ | |
#asm | |
call 0be53h | |
ld l,a | |
ld h,0 | |
#endasm | |
} | |
int peek(int addr) | |
{ | |
#asm | |
ld a,(hl) ; addr | |
ld l,a | |
ld h,0 | |
#endasm | |
} | |
void wait(int count) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld c,(ix+2) ; count | |
ld b,(ix+3) | |
loop_wait: | |
dec bc | |
ld a,b | |
or c | |
jr nz,loop_wait | |
#endasm | |
} | |
unsigned int r; | |
unsigned char rnd() | |
{ | |
r++; | |
r ^= r >> 3; | |
r ^= r << 5; | |
r ^= r >> 7; | |
return(r); | |
} | |
char balloon[] = { 0x1c, 0x3e, 0x7f, 0xff, 0x7d, 0x3a, 0x1c}; | |
char ribbon[] = { 0x00, 0x00, 0x00, 0x99, 0x66}; | |
void main() | |
{ | |
r = peek(0x7a9c); | |
for(int y=0; y<8; y++) { | |
outp(0x40, 0xb0+y); /* y position (charcters) */ | |
outp(0x40, 0x00); /* x position (dots, l=0) */ | |
outp(0x40, 0x10); /* x position (dots, h=0) */ | |
/* Note: Y position 144 (90H) is the state */ | |
outpr(0x41, 0, 145); /* data */ | |
} | |
while(getcodei()) {} | |
while(!getcodei()) | |
{ | |
for(int s=0; s<8; s++) { | |
outp(0x40, 0xb0+(s+7)%8); /* y position (charcters) */ | |
outp(0x40, 0x00); /* x position (dots, h=0) */ | |
outp(0x40, 0x10); /* x position (dots, l=0) */ | |
outpr(0x41, 0, 144); /* data */ | |
int r=rnd()%137; | |
outp(0x40, 0xb0+(s+6)%8); /* y position (charcters) */ | |
outp(0x40, 0x00+r%16); /* x position (dots, l) */ | |
outp(0x40, 0x10+r/16); /* x position (dots, h) */ | |
outpir(0x41, balloon, 7); /* data */ | |
for(int y=0; y<8; y++) { | |
outp(0x40, 0x40+s*8+y); /* scroll y position */ | |
wait(11111); | |
if(getcodei()) | |
{ | |
break; | |
} | |
} | |
outp(0x40, 0xb0+(s+7)%8); /* y position (charcters) */ | |
outp(0x40, 0x00+r%16); /* x position (dots, l) */ | |
outp(0x40, 0x10+r/16); /* x position (dots, h) */ | |
outpir(0x41, ribbon, 5); /* data */ | |
if(getcodei()) | |
{ | |
break; | |
} | |
} | |
} | |
} |
Author
fu-sen
commented
Feb 16, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment