Last active
May 6, 2016 06:34
-
-
Save ArcadeHacker/44cdf7dc03638c2f271ca8b5b6a77fef to your computer and use it in GitHub Desktop.
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
// By ajhippel | |
// Crazy climber is one of the pcb's where the main cpu controlles the soundchip, which is the same like on the atari st.. | |
// only the clock for the soundchip is a bit lower, but i transposed the song a bit higher... | |
// it's just a z80 player instead of the 68000 play-routine i used the old days... | |
// unfortunately there is only one interrupt (about 60hz) and no timer...with a timer i could add sid-voice and everything... | |
// the sine is indeed VERY simple... | |
// crazy climber has 32 scroll-registers for each column...wow i never had that on an atari st :) | |
// thats why the code is VERY short: | |
initialisation: | |
ld hl,sineoffsets ;pointer in the ram | |
ld b,32 ;32 columns | |
initsineoffsets: | |
ld a,b ;get b (32-1) as startdely | |
dec a ;make it 31-0) | |
ld (hl),a ;store delay | |
inc hl ;next column | |
djnz initsineoffsets | |
// and this is the sine-program: | |
dosine: | |
ld hl,sineoffsets ;points to 32 bytes free ram | |
ld de,#9800 ;pointer to the 32 scroll-registers | |
ld b,32 ;32 columns | |
dosinelp: | |
ld a,(hl) ;get offset in the sinetable | |
and a ; | |
jp m,sinewave ;when minus, then do the sine | |
dec a ;when positive, count down delay | |
ld (hl),a ;store it again | |
inc hl ;next column (ram) | |
inc de ;next column (scrollregister) | |
djnz dosinelp | |
ret | |
sinewave: | |
inc a ;increment offset | |
or #80 ;always make it negative (positive would be the initial delay) | |
ld (hl),a ;store offset | |
and #7f ;only 0-127 | |
push hl ;store the pointer | |
ld h,HI sinetable ;get the high-byte of the sinetable-address | |
ld l,a ;offset = lowbyte of the address | |
ld a,(hl) ;get value from table | |
pop hl ;get the pointer again | |
inc hl ;increase the pointer | |
ld (de),a ;store value in the scroll-register | |
inc de ;increase pointer | |
djnz dosinelp ;next column | |
ret | |
// just make sure that the 128 bytes sinetable does not cross a 256 bytes border |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment