; The Entropy Experience menu ;----------------------------- ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» ;ºNOTE: This appears to be a very old version of the source. My original discº ;ºwith this on corrupted, so it is missing most of the code from the routinesº ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ;(c) 11-11-93 Simon Cooke (COOKIE) ;Graphics by Simon Cooke, SAM PRIME logo by Steve Pick ;Music by Roger Hartley (DR. H) on E-Tracker ;This source has been commented and sold as part of the ;Entropy Experience Source-Code disc... ;It is to be distributed or copied. ;If you use routines taken from this code, or routines based ;on it, please credit me somewhere in it - it's nice to see ;my name! ;On with the show... ;Send all correspondance to: ;E-mail: csl@fs2.ee.umist.ac.uk ;Post: 18 Braemar Drive, Sale, Cheshire, M33 4NJ, ENGLAND ;EQUATES: ;-------- lmpr: EQU &FA hmpr: EQU &FB vmpr: EQU &FC pen: EQU &F8 vid.page: EQU 30 mode2: EQU 32 mode4: EQU 96 stat: EQU &F9 border: EQU &FE ;Code starts in higher memory when called, then drops down to ;lower memory... ORG 0 DUMP 1,0 start: DI LD A,128 ;set border to black OUT (border),A ;turn screen off ;Quick set to black for palette - uses an undocumented opcode ;previously unpublished anywhere by anyone - a Cookie Special! ;NB: It took a long time to find... There's another one, that ;corresponds to IN, but I haven't tried to use it yet... LD BC,&10F8 ;&10f8 - CLUT 16 = CLUT 0 black.out: DEFB &ED,&71 ; OUT (C),0 DJNZ black.out ;Store BASIC paging/stack settings IN A,(lmpr) LD (lmpr.store+&8001),A IN A,(vmpr) LD (vmpr.store+&8001),A LD (sp.store+&8001),SP ;NB: the &8001 is because 1) the code is self-modifying ;2) the routine is paged high, but assembles as if low LD A,33 ;page 1, rom off OUT (lmpr),A JP intro ;Return to basic routine ret.to.basic: DI LD A,1 OUT (hmpr),A JP jumphigh+&8000 jumphigh: lmpr.store: LD A,&00 ;self-modifying store for OUT (lmpr),A ;BASIC lmpr setting vmpr.store: LD A,&00 OUT (vmpr),A sp.store: LD SP,&0000 EI RET ;return to basic totally spare.space: ;free bytes to be used DEFS 2 ;Interrupt handling routine ;--------------------------- ;Routine starts at &38 ;Again, self-modifying, thus vectorable to varying line and ;frame interrupt handling routines... Used for having a ;different routine in the intro, to the menu etc. ;Note: no need for DI - Z80 automatically disables interrupts ;when an interrupt occurs... interrupts: PUSH AF IN A,(stat) ;interrupt status RRA current.line: JP NC,exit.int ;bit 0 = 0 --> line interr. BIT 2,A current.frame: JP Z,exit.int ;bit 2 (due to shift) ; = 0 --> frame interr. exit.int: POP AF EI RET clear.screen: LD HL,&8000 ;clear screen area using LDIR LD DE,&8001 ;to fill the area with zeroes LD BC,24575 ;If you can't work out how LD (HL),L ;it's doing it, sit down and LDIR ;work through it step by step RET ;SET PALETTE COLOURS: ;Entered with HL pointing to start of palette data + 15 set.palette: LD BC,&10F8 ;CLUT 16... OTDR RET ;Wait for frame interrupt to occur - for synchronisation wait.frame: DI loop.fr: IN A,(stat) BIT 3,A JR NZ,loop.fr CALL keycheck ;get keypresses EI RET ;NMI handler routine ;------------------- nmi.handler: ;just return, ignoring the interrupt. RETN alternate.sp: DEFS 256 music.code: init.music: play.music: EQU init.music+6 MDAT "EXPTUNE" play.msc: ;store all registers and play the tune PUSH HL PUSH BC PUSH DE EXX PUSH HL PUSH BC PUSH DE EX AF,AF' PUSH AF PUSH IX PUSH IY CALL play.music POP IY POP IX POP AF EX AF,AF' POP DE POP BC POP HL EXX POP DE POP BC POP HL JP exit.int ;Frame interrupt routine... check.key: CALL keycheck JP exit.int ;Check for key-press (used in INTRO) keycheck: LD A,&7F ;check for space being pressed IN A,(border) RRA RET C keypr: LD A,&00 ;flag for skip-intro detect OR A JP Z,main.jump RET ;Main menu code starts here: ;-=-=-=-=-=-=-=-=-=-=-=-=-=- intro: LD SP,alternate.sp+256 ;128 entry stack space LD HL,exit.int LD (current.line+1),HL LD HL,check.key LD (current.frame+1),HL LD A,192 ;set line-interrupts to line OUT (stat),A ;192 ;(disable them) LD A,vid.page+mode4 ;page in screen at 32768 OUT (vmpr),A LD A,vid.page OUT (hmpr),A CALL clear.screen XOR A ;turn screen back on, border OUT (border),A ;colour 0 CALL init.music ;initialise music, ;clear sound chip EI ;NB: sound chip resetting is handled by ESI's code CALL entropy.disp ;do a fancy appearance for ;the entropy logo (just fades in) CALL clear.screen LD BC,50 CALL wait CALL inbetween ;display "in association with" CALL clear.screen LD BC,50 CALL wait CALL prime.disp ;display SAM PRIME logo CALL clear.screen LD BC,50 CALL wait CALL presents ;display PRESENTS gfx LD BC,50 CALL wait CALL clear.screen ;Dump stack pointer, and draw main menu screen main.jump: DI LD A,1 ;disable jump on keypress LD (keypr+1),A LD HL,exit.int LD (current.frame+1),HL LD SP,alternate.sp+256 LD BC,&10F8 ;&10f8 - CLUT 16 = CLUT 0 black.out2: DEFB &ED,&71 ; OUT (C),0 DJNZ black.out2 CALL clear.screen EI CALL draw.menu main.menu: LD HL,play.msc LD (current.frame+1),HL main.loop: LD A,&7F ;check for symbol -- must be early IN A,(border) ;version of code! RRA RRA JR C,main.loop JP ret.to.basic ;Display "In association with" text inbetween: LD HL,tween.pal CALL movecolours LD HL,tween.logo LD BC,&1170 ;height (B)=17, width(C)=112 ;NB: this routine puts a logo central on the screen... CALL put.logo CALL fadein LD BC,110 CALL wait ;waits for 5 seconds CALL fadeout RET ;Fade in SAM PRIME logo prime.disp: LD HL,prime.pal CALL movecolours LD HL,prime.logo LD BC,&4957 CALL put.logo CALL fadein LD BC,110 CALL wait CALL fadeout RET presents: LD A,vid.page+mode2 OUT (vmpr),A LD HL,tween.pal CALL movecolours LD HL,&A000 LD DE,&A001 LD BC,6143 LD (HL),7 ;white... LDIR LD HL,pres.logo LD DE,&8800 LD BC,32*64 LDIR CALL fadein LD BC,110 CALL wait CALL fadeout RET ;Wait for a given number of frames (in BC) wait: PUSH BC CALL wait.frame POP BC DEC BC LD A,B OR C JR NZ,wait RET ;Put a logo on the screen, central as possible - entered with ;HL=start address of logo, B=height of logo, C=width of logo put.logo: LD (start.logo+1),HL LD A,C LD (width.logo+1),A LD A,B LD (height.logo+1),A SRL B ;divide height and width by 2 SRL C LD HL,&B000 ;midway into screen, paged in ;high memory LD D,B LD E,0 SRL D ;effectively, DE=b*128 RR E AND A SBC HL,DE ;logo is now centred vertical LD A,64 SUB C LD E,A LD D,0 ADD HL,DE ;now centered horiz. EX DE,HL start.logo: LD HL,&0000 ;self-modifying as ever height.logo: LD B,&00 logo.loop: PUSH DE PUSH BC width.logo: ;uses LDIR for compactness LD BC,&0000 LDIR POP BC POP DE PUSH HL LD HL,128 ADD HL,DE EX DE,HL ;point DE to next screen line POP HL DJNZ logo.loop RET ;My oldest generic routine that I keep on file: ;This is the fader that appeared in a very much butchered ;form on one of the early FREDs (thanks Colin) ;Originally written on LERM (Yeuck), which is why it is so ;badly organised... I now keep labels on separate lines except ;for in DATA areas... ;The logic behind it was discussed in Chris's Space Invaders ;source on FRED - but never released (as far as I can remember) ; ;These routines will fade out /fade in any screen ;with any colours ;To use follow the following path ; ;1) First load HL with the address of you palette ; address.Then call MOVECOLOURS ; ;2) Then call FADEOUT to fade the screen to black ; FADEIN to fade the screen to its colours ; ;This may be repeated as many times as you require ;for further help follow the comments in the text file ; ;Copyright Simon Cooke ;Alterations by Chris White 1991, Simon Cooke 12-11-93 fadeout: LD HL,palette LD DE,temppalette LD BC,16 LDIR LD B,8 fadeout1: LD C,16 LD HL,temppalette fadeout2: LD A,(HL) CALL dropdown LD (HL),A INC HL DEC C JP NZ,fadeout2 EXX CALL wait.frame CALL wait.frame LD HL,temppalette+15 LD BC,&10F8 OTDR EXX DJNZ fadeout1 RET fadein: LD B,9 LD D,8 fadein1: LD C,16 LD HL,palette EXX LD HL,temppalette EXX fadein2: PUSH DE LD A,(HL) INC D DEC D JP Z,nofadein fadein3: PUSH DE CALL dropdown POP DE DEC D JP NZ,fadein3 nofadein: INC HL EXX LD (HL),A INC HL EXX POP DE DEC C JP NZ,fadein2 EXX CALL wait.frame CALL wait.frame LD HL,temppalette+15 LD BC,&10F8 OTDR EXX DEC D DJNZ fadein1 RET dropdown: OR A RET Z XOR 8 BIT 3,A RET Z dropblue: LD D,A AND 17 JP NZ,nextdown1 LD A,D JP dropred nextdown1: AND 1 JP Z,drophighblue LD A,D AND 126 JP dropred drophighblue: LD A,D AND 111 OR 1 dropred: LD D,A AND 34 JP NZ,nextdown2 LD A,D JP dropgreen nextdown2: AND 2 JP Z,drophighred LD A,D AND 125 JP dropgreen drophighred: LD A,D AND 127-32 OR 2 dropgreen: LD D,A AND 68 JP NZ,nextdown3 LD A,D RET nextdown3: AND 4 JP Z,drophighgreen LD A,D AND 123 RET drophighgreen: LD A,D AND 63 OR 4 RET movecolours: LD DE,palette LD BC,16 LDIR RET palette: DEFS 16 temppalette: DEFS 16 ;This is the line dropper routine used in various forms on the ;Happy Birthday and Entro 2 demos - both the same, different ;drag co-efficients... entropy.disp: LD HL,entropy.pal CALL movecolours LD HL,entropy.pal+15 CALL set.palette DI LD HL,drop.table LD B,64 drop.set: LD (HL),0 INC HL DJNZ drop.set next.drop: LD A,111 LD (min.height+1),A XOR A LD (dropper.count+1),A LD (add.line+1),A dropper.loop: LD A,1 IN A,(pen) CP 115 JR NZ,dropper.loop LD A,&7F IN A,(border) RRA JP NC,main.jump LD HL,drop.table LD (sp.drop+1),SP LD A,(add.line+1) LD B,A drop.clear: LD A,B OR A JR Z,sp.drop LD A,(HL) INC HL INC HL DEC B CP 255 JR Z,drop.clear LD D,A LD E,231 SCF RR D RR E EX DE,HL LD SP,HL EX DE,HL LD DE,0 PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE PUSH DE INC SP PUSH DE JR drop.clear sp.drop: LD SP,&0000 LD A,&FF LD (current.one+1),A LD HL,drop.table LD A,(add.line+1) LD B,A drop.update: PUSH HL LD HL,current.one+1 INC (HL) POP HL LD A,B OR A JR Z,drop.shower LD A,(HL) CP 255 JR NZ,not.skip.drop INC HL INC HL DEC B JR drop.update not.skip.drop: LD E,A ;E holds height INC HL LD A,(HL) ;A holds veloctity (2's comp) ADD A,2 ;add gravity LD (HL),A ADD A,E LD (rest.a+1),A min.height: ;bounce off floor LD A,111 current.one: LD D,0 LD A,111 SUB D LD D,A rest.a: LD A,0 CP D JR C,okay JR Z,okay DEC HL LD A,(current.one+1) LD D,A LD A,111 SUB D LD (HL),A INC HL LD A,(HL) ;just hit the floor instead NEG JR drag.coeff+1 okay: DEC HL LD (HL),A INC HL drag.coeff: LD A,(HL) ;drag effect comes here OR A JR Z,not.ddrop BIT 7,A JR NZ,not.dec.drop drag1: SUB 0 JR not.ddrop not.dec.drop: drag2: ADD A,1 not.ddrop: LD (HL),A INC HL DEC B JR drop.update drop.shower: LD A,(add.line+1) LD B,A LD C,1 LD HL,drop.table LD A,32 LD (curr.l+1),A showerd.loop: LD A,B OR A JP Z,dropper.exit LD A,(curr.l+1) DEC A LD (curr.l+1),A LD A,(HL) CP 255 JR NZ,not.inactive INC HL INC HL DEC B JR showerd.loop not.inactive: EX DE,HL LD HL,min.height+1 CP (HL) JR NZ,put.line EX DE,HL INC HL LD A,(HL) OR A JR NZ,not.zero.vel EX DE,HL LD HL,min.height+1 DEC (HL) EX DE,HL DEC HL LD A,(HL) LD (HL),&FF JR put.line2 not.zero.vel: DEC HL LD A,(HL) JR put.line2 put.line: EX DE,HL put.line2: LD C,0 LD D,A LD E,25 SCF RR D RR E PUSH HL PUSH BC PUSH DE curr.l: LD HL,0 ADD HL,HL LD DE,line.table ADD HL,DE LD E,(HL) INC HL LD D,(HL) EX DE,HL POP DE LD BC,103 LDIR POP BC POP HL INC HL INC HL DEC B JR showerd.loop dropper.exit: LD A,C OR A JR Z,dropper.count AND 1 LD (drag1+1),A LD (drag2+1),A LD A,(add.line+1) CP 32 JP Z,dropper.end dropper.count: LD A,0 OR A CALL Z,add.line DEC A LD (dropper.count+1),A JP dropper.loop dropper.end: EI LD BC,125 CALL wait CALL fadeout RET add.line: LD A,0 CP 32 JR Z,exit.addl INC A LD (add.line+1),A DEC A LD L,A LD H,0 ADD HL,HL LD DE,drop.table ADD HL,DE LD (HL),0 INC HL LD (HL),0 exit.addl: LD A,7 RET drop.table: DEFS 64 draw.menu: RET entropy.pal: DEFB 0,29,91,32,34,38,98,102,68,8,7,15,112,120 DEFB 119,127 tween.pal: DEFB 0,8,7,15,112,120,119,127 DEFB 0,8,7,15,112,120,119,127 prime.pal: DEFB 0,21,16,23,17,2,32,34,42,21,16,64,68 DEFB 85,38,16 tween.logo: MDAT "tween.dat" prime.logo: MDAT "prime.dat" pres.logo: MDAT "pres.dat" entropy.logo: MDAT "entro.dat" ;Table of values for line positions ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ line.table: DEFW entropy.logo DEFW entropy.logo+103 DEFW entropy.logo+206 DEFW entropy.logo+309 DEFW entropy.logo+412 DEFW entropy.logo+515 DEFW entropy.logo+618 DEFW entropy.logo+721 DEFW entropy.logo+824 DEFW entropy.logo+927 DEFW entropy.logo+1030 DEFW entropy.logo+1133 DEFW entropy.logo+1236 DEFW entropy.logo+1339 DEFW entropy.logo+1442 DEFW entropy.logo+1545 DEFW entropy.logo+1648 DEFW entropy.logo+1751 DEFW entropy.logo+1854 DEFW entropy.logo+1957 DEFW entropy.logo+2060 DEFW entropy.logo+2163 DEFW entropy.logo+2266 DEFW entropy.logo+2369 DEFW entropy.logo+2472 DEFW entropy.logo+2575 DEFW entropy.logo+2678 DEFW entropy.logo+2781 DEFW entropy.logo+2884 DEFW entropy.logo+2987 DEFW entropy.logo+3090 DEFW entropy.logo+3193