Last active
April 19, 2025 02:11
-
-
Save fu-sen/f361c7e1dde3694368f822c78c4612b6 to your computer and use it in GitHub Desktop.
Balloons version 2 - PC-G815 - 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-G815 | z88dk C language | |
Copyright (c) 2025 BALLOON | FU-SEN | |
The MIT License (MIT) - https://mit.balloon.net.eu.org/#2025 | |
There is a problem with the operation with emulator g800! | |
(version 0.11.4 and 20240414 (beta)) | |
zcc +g800 -create-app -bn balloon2 balloon2.c | |
--> MON | |
R | |
G100 | |
*/ | |
void putchr(char posx, char posy, char pchr) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; pchr | |
ld d,(ix+4) ; posy | |
ld e,(ix+6) ; posx | |
call 0be62h | |
#endasm | |
} | |
void putimg(char posx, char posy, 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 d,(ix+6) ; posy | |
ld e,(ix+8) ; posx | |
call 0bfd0h | |
#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 poke(int addr, char value) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; value | |
ld l,(ix+4) ; addr | |
ld h,(ix+5) | |
ld (hl),a | |
#endasm | |
} | |
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 | |
} | |
unsigned int r; | |
unsigned char rnd() | |
{ | |
r++; | |
r ^= r >> 3; | |
r ^= r << 5; | |
r ^= r >> 7; | |
return(r); | |
} | |
char buf[144*8] = { 0 }; | |
char balloon[] = { 0x1c, 0x3e, 0x7f, 0xff, 0x7d, 0x3a, 0x1c}; | |
char ribbon[] = { 0x00, 0x00, 0x00, 0x99, 0x66, 0x00, 0x00}; | |
void main() | |
{ | |
int scry = peek(0x790d); | |
r=255; | |
for(int y=0; y<4; y++) { | |
for(int x=0; x<24; x++) { | |
putchr(x, y,' '); | |
} | |
} | |
for(int y=0; y<7; y++) { | |
outp(0x58, 0x7f); | |
outp(0x58, 0xb8+y); | |
outp(0x5a, 0); | |
} | |
while(getcodei()) {} | |
while(!getcodei()) | |
{ | |
unsigned int oldr=r; | |
if (r==255) { | |
r = peek(0x7a9c); | |
} | |
r=rnd()%137; | |
for (int y=0; y<8; y++) { | |
outp(0x54, 0xc0+scry*8+y); | |
outp(0x58, 0xc0+scry*8+y); | |
for (int x=0; x<144; x++) { | |
buf[scry*144+x] &= (255 - (1 << y)); | |
} | |
for (int x=0; x<7; x++) { | |
buf[scry*144+r+x] |= (balloon[6-x] & (1 << y)); | |
} | |
if(oldr<255) | |
{ | |
for (int x=0; x<7; x++) { | |
buf[scry*144+oldr+x] |= (ribbon[6-x] & (1 << y)); | |
} | |
} | |
if(getcodei()) | |
{ | |
break; | |
} | |
putimg(0, 0, buf+scry*144, 144); | |
} | |
for (int x=0; x<144; x++) { | |
buf[((scry+4)%8)*144+(143-x)] = buf[scry*144+x]; | |
} | |
scry++; | |
scry %= 8; | |
poke(0x790d, scry); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment