Last active
September 4, 2022 11:23
-
-
Save fu-sen/4a64e2978d42bd5c175b248755a8f576 to your computer and use it in GitHub Desktop.
風船 Balloons version 2 | MSX-BASIC 2.0+ (MSX2/MSX2+/turbo R) / z88dk https://msxjpn.jimdofree.com/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/%E9%A2%A8%E8%88%B9/
This file contains 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 | MSX-BASIC 2.0+ / z88dk | |
Copyright (c) 2019 Keiichi Shiga (BALLOON | FU-SEN) | |
The MIT License (MIT) - https://mit.balloon.net.eu.org/#2019 | |
zcc +msx -lndos -create-app -subtype=disk -bn balloons balloons.c | |
--> BLOAD"BALLOONS.MSX",R | |
*/ | |
void wrtvdp(char reg, char data) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld b,(ix+2) ; data | |
ld c,(ix+4) ; reg | |
call 0047h ; WRTVRM | |
#endasm | |
} | |
void wrtvrm(int addr, char data) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; data | |
ld l,(ix+4) ; addr | |
ld h,(ix+5) | |
call 004dh ; WRTVRM | |
#endasm | |
} | |
void filvrm(int addr, int size, char data) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; data | |
ld c,(ix+4) ; size | |
ld b,(ix+5) | |
ld l,(ix+6) ; addr | |
ld h,(ix+7) | |
call 0056h ; FILVRM | |
#endasm | |
} | |
void ldirvm(int addr, int vaddr, int size) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld c,(ix+2) ; size | |
ld b,(ix+3) | |
ld e,(ix+4) ; vaddr | |
ld d,(ix+5) | |
ld l,(ix+6) ; addr | |
ld h,(ix+7) | |
call 005ch ; LDIRVM | |
#endasm | |
} | |
void chgclr(char forclr, char bakclr, char bdrclr) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; BDRCLR | |
ld (0f3ebh),a | |
ld a,(ix+4) ; BAKCLR | |
ld (0f3eah),a | |
ld a,(ix+6) ; FORCLR | |
ld (0f3e9h),a | |
call 0062h ; CHGCLR | |
#endasm | |
} | |
void init32() | |
{ | |
#asm | |
call 006fh ; INIT32 | |
#endasm | |
} | |
void cls() | |
{ | |
#asm | |
xor a ; ld a,0 | |
call 00c3h ; CLS | |
#endasm | |
} | |
int gttrig(char btn) | |
{ | |
#asm | |
ld a,l ; btn | |
call 00d8h ; GTTRIG | |
ld l,a | |
ld h,0 | |
#endasm | |
} | |
void kilbuf() | |
{ | |
#asm | |
call 00156h ; KILBUF | |
#endasm | |
} | |
void height212() | |
{ | |
#asm | |
ld hl,0ffe8h ; rg9sav | |
set 7,(hl) | |
ld a,(hl) | |
ld b,a | |
ld c,9 ; R#9 | |
call 0047h ; WRTVDP | |
#endasm | |
} | |
void poke(int addr, char data) | |
{ | |
#asm | |
ld ix,0 | |
add ix,sp | |
ld a,(ix+2) ; data | |
ld l,(ix+4) ; addr | |
ld h,(ix+5) | |
ld (hl),a | |
#endasm | |
} | |
int peek(int addr) | |
{ | |
#asm | |
ld a,(hl) | |
ld l,a | |
ld h,0 | |
#endasm | |
} | |
unsigned int r; | |
unsigned char rnd() | |
{ | |
r=(r*5)+1; | |
return(r); | |
} | |
char balloon[8] = {0x38,0x74,0xfa,0xfe,0xfe,0x7c,0x38,0x10}; | |
char ribbon[8] = {0x10,0x08,0x08,0x10,0x10,0x08,0x08,0x10}; | |
int s=0,y=27; | |
void main() | |
{ | |
r=peek(0xfc9e); | |
chgclr(15, 1, 1); | |
init32(); | |
height212(); | |
cls(); | |
filvrm(0x1800+24*32, 32*8, 32); | |
for(int c=2; c<16; c++){ | |
ldirvm(balloon, (120+c*8)*8, 8); | |
wrtvrm(0x2000+(120/8)+c, c*16+1); | |
} | |
ldirvm(ribbon, 248*8, 8); | |
while(!gttrig(0)){ | |
int c=rnd()%14+1; | |
int x=rnd()%30+1; | |
int temp=rnd(); | |
wrtvrm(0x1800+y*32+x, 128+c*8); | |
for(int ss=0; ss<8; ss++){ | |
wrtvdp(23, s+ss); | |
int tim=peek(0xfc9e); | |
while(peek(0xfc9e)==tim && !gttrig(0)) ; | |
} | |
s=(s+8)%256; | |
wrtvdp(23, s); | |
y=(y+1)%32; | |
filvrm(0x1800+y*32, 32, 32); | |
wrtvrm(0x1800+y*32+x, 248); | |
} | |
chgclr(15, 4, 7); | |
init32(); | |
kilbuf(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment