Skip to content

Instantly share code, notes, and snippets.

@fu-sen fu-sen/balloons-dos.c
Last active Jul 12, 2019

Embed
What would you like to do?
風船 Balloons version 2 MSX-DOS .com version | MSX-DOS / MSX2 / z88dk https://msxjpn.jimdo.com/ https://msx.surge.sh/balloons.com
/*
Balloons version 2 MSX-DOS .com version | MSX-DOS / MSX2 / z88dk
Copyright (c) 2019 Keiichi SHIGA (BALLOON a.k.a. Fu-sen.)
The MIT License (MIT) - https://gist.github.com/fu-sen/7e55ee56a67e07d804db9379178e3cb5
zcc +msx -subtype=msxdos -bn balloons.com balloons-dos.c
(MSX-DOS 2.30+ set the following: SET EXPERT ON )
--> BALLOONS
*/
void wrtvdp(char reg, char data)
{
#asm
ld ix,0
add ix,sp
ld b,(ix+2) ; data
ld c,(ix+4) ; reg
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,0047h ; WRTVRM
call 001ch ; CALSLT
#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)
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,004dh ; WRTVRM
call 001ch ; CALSLT
#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)
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,0056h ; FILVRM
call 001ch ; CALSLT
#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
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,0062h ; CHGCLR
call 001ch ; CALSLT
#endasm
}
void init32()
{
#asm
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,006fh ; INIT32
call 001ch ; CALSLT
#endasm
}
int chsns()
{
#asm
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,009ch ; INIT32
call 001ch ; CALSLT
ld l,0
ld h,0
ret z
ld l,0ffh
#endasm
}
void cls()
{
#asm
xor a ; ld a,0
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,00c3h ; CLS
call 001ch ; CALSLT
#endasm
}
void kilbuf()
{
#asm
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,0156h ; KILBUF
call 001ch ; CALSLT
#endasm
}
void height212()
{
#asm
ld hl,0ffe8h ; rg9sav
set 7,(hl)
ld a,(hl)
ld b,a
ld c,9 ; R#9
ld iy,(0fcc1h-1) ; EXPTBL-1
ld ix,0047h ; WRTVDP
call 001ch ; CALSLT
#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()
{
kilbuf();
r=peek(0xfc9e);
chgclr(15, 1, 1);
init32();
height212();
cls();
filvrm(0x1800+24*32, 32*8, 32);
for(int c=2; c<16; c++){
for(int d=0;d<8;d++){
wrtvrm((120+c*8)*8+d, balloon[d]);
}
wrtvrm(0x2000+(120/8)+c, c*16+1);
}
for(int d=0;d<8;d++){
wrtvrm(248*8+d, ribbon[d]);
}
while(!chsns()){
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 && !chsns()) ;
}
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
You can’t perform that action at this time.