home *** CD-ROM | disk | FTP | other *** search
- ; *******************************************************************
- ; * Amstrad CPC emulator *
- ; * © 1991/92 Bernd Schmidt *
- ; * *
- ; * CPC ROM code substitutes in 68000 code *
- ; * *
- ; *******************************************************************
-
- INCLUDE "cpe.inc"
-
- XDEF initcode
-
- XREF amscode,bascode,ro7code
- XREF simz80,sz80l,calcpca,stack
- XREF wword,wbyte,gword,gbyte
- XREF dosbase,fhandle,DiskBuf
- XREF DCSeekCurr,idfield,IDTPtr,CurrTrack,trackoffs
- XREF KeyMatrix
- SECTION substitutes68,CODE
-
- ; Whoops! This stuff is DISABLED, because it only works with the 664 ROM!
- ; It does nothing but to speed up some code slightly.
- initcode:
- lea amscode,a0
- move.l #$C01,d5
- add.l d5,d5
- add.l d5,d5
- move.l #SCRNEXTBYTE,0(a0,d5.l)
- move.l #$C0D,d5
- add.l d5,d5
- add.l d5,d5
- move.l #SCRPREVBYTE,0(a0,d5.l)
- move.l #$C1B,d5
- add.l d5,d5
- add.l d5,d5
- move.l #SCRNEXTLINE,0(a0,d5.l)
- move.l #$C35,d5
- add.l d5,d5
- add.l d5,d5
- move.l #SCRPREVLINE,0(a0,d5.l)
- move.l #$B66,d5
- add.l d5,d5
- add.l d5,d5
- move.l #SCRCHARPOSITION,0(a0,d5.l)
- move.l #$1e2,d5
- add.l d5,d5
- add.l d5,d5
- move.l #KLEVENT,0(a0,d5.l)
- move.l #$873,d5
- add.l d5,d5
- add.l d5,d5
- move.l #MCSCANKEYBOARD,0(a0,d5.l)
-
- move.l #$067C,d5
- add.l d5,d5
- add.l d5,d5
- lea ro7code,a0
- move.l #HandleSector,0(a0,d5.l)
- move.l #$09CD,d5 ; Motor On New Ticker
- add.l d5,d5
- add.l d5,d5
- move.l #FloppySetTicker,0(a0,d5.l)
- moveq #0,d5
- rts
-
- MCSCANKEYBOARD:
- movem.l d7/a6,-(sp)
- lea KeyMatrix,a6
- moveq #9,d7
- MCSC_Loop:
- move.w sHL,d5
- jsr gbyte
- and.b (a6),d6
- not.b d6
- move.w sDE,d5
- jsr wbyte
- move.w sHL,d5
- move.b (a6)+,d6
- jsr wbyte
- addq.w #1,sHL
- addq.w #1,sDE
- dbf d7,MCSC_Loop
- move.w #$F600,sBC
- move.b #$82,sA
- movem.l (sp)+,d7/a6
- bra code68_ret80
-
- KLEVENT:
- addq.w #2,sHL
- move.w sHL,d5
- jsr gbyte
- move.b d6,sA
- addq.b #1,d6
- move.w d6,-(sp)
- jsr wbyte
- move.w (sp)+,d6
- btst #7,d6
- beq KLEV_notneg
- subq.b #1,d6
- move.w sHL,d5
- jsr wbyte
- bra code68_ret80 ; KLEV200
- KLEV_notneg:
- tst.b sA
- bne code68_ret80 ; KLEV200
- move.w sHL,d5
- addq.w #1,d5
- jsr gbyte
- move.b d6,sA
- tst.b sA
- bpl KLEV_22F
- swap d1
- btst #0,d1
- beq KLEV_209
- swap d1
- add.b sA,sA
- bpl KLEV_E8
- addq.w #2,sHL
- bra KLEV_223
- KLEV_209:
- move.w #$20A,d7
- jmp calcpca
- KLEV_223:
- move.w sHL,d5
- jsr gword
- addq.w #1,sHL
- move.w sHL,sDE
- move.w d6,sDE
- move.w d6,sPC
- jmp calcpca
- KLEV_22F:
- move.w #$22e,d7
- jmp calcpca
- KLEV_E8:
- move.w #$e8,d7
- jmp calcpca
-
- SCRCHARPOSITION:
- move.l sDE,-(sp)
- move.w #$B7c3,d5
- move.b 0(a4,d5.w),d5
- moveq #4,d6
- cmp.b #0,d5
- beq SCCPOS_gotmode
- moveq #2,d6
- cmp.b #1,d5
- beq SCCPOS_gotmode
- moveq #1,d6
- SCCPOS_gotmode:
- rol.w #8,sBC
- move.b d6,sBC
- rol.w #8,sBC
- move.l sBC,-(sp)
- move.w sHL,sDE
- rol.w #8,sDE
- and.w #$FF,sDE
- and.w #$FF,sHL
- move.w sHL,d6
- add.w sHL,sHL
- add.w sHL,sHL
- add.w d6,sHL
- add.w sHL,sHL
- add.w sHL,sHL
- add.w sHL,sHL
- add.w sHL,sHL
- move.w sBC,d6
- and.w #$FF00,d6
- SCCPOS_addcol
- add.w sDE,sHL
- sub.w #$100,d6
- bne SCCPOS_addcol
- and.w #$FF,sBC
- move.w #$B7c4,d5
- jsr gword
- add.w d6,sHL
- and.w #$7ff,sHL
- move.w #$b7c6,d5
- moveq #0,d6
- move.b 0(a4,d5.w),d6
- rol.w #8,d6
- add.w d6,sHL
- move.l (sp)+,sBC
- move.l (sp)+,sDE
- bra code68_ret80
-
- SCRNEXTBYTE:
- move.w sHL,d5
- addq.w #1,d5
- and.w #$7FF,d5
- and.w #$F800,sHL
- or.w d5,sHL
- bra code68_ret80
-
- SCRPREVBYTE:
- move.w sHL,d5
- subq.w #1,d5
- and.w #$7FF,d5
- and.w #$F800,sHL
- or.w d5,sHL
- bra code68_ret80
-
- SCRNEXTLINE:
- move.w sHL,d5
- add.w #$800,d5
- and.w #$C7FF,sHL
- and.w #$3800,d5
- beq SNXL_RAover
- or.w d5,sHL
- bra code68_ret80
- SNXL_RAover
- add.w #$50,sHL
- and.w #$C7FF,sHL
- bra code68_ret80
-
- SCRPREVLINE:
- move.w sHL,d5
- sub.w #$800,d5
- and.w #$C7FF,sHL
- and.w #$3800,d5
- cmp.w #$3800,d5
- beq SNPL_RAover
- or.w d5,sHL
- bra code68_ret80
- SNPL_RAover
- sub.w #$50,sHL
- and.w #$C7FF,sHL
- or.w d5,sHL
- bra code68_ret80
-
- FloppyHardRet:
- code68_ret80:
- move.w stack,d5
- jsr gword
- add.w #2,stack
- move.w d6,sPC
- jsr calcpca
- rts
-
- FloppySetTicker:
- clr.w sBC
- move.w #2,sDE
- move.w #$BE67,sHL
- move.w #$BCE9,sPC
- jsr calcpca
- rts
-
- SeekTrack:
- movem.l d0-d7/a0-a6,-(sp)
- move.w sDE,d5
- lsr.w #8,d5
- and.l #$3F,d5
- move.b d5,CurrTrack
- jsr DCSeekCurr
- movem.l (sp)+,d0-d7/a0-a6
- or.w #1,sF
- move.w stack,d5
- jsr gword
- add.w #2,stack
- move.w d6,sPC
- jsr calcpca
- rts
-
- GetNextID:
- move.l IDTPtr,a0
- move.b (a0)+,d6
- cmp.b #$FF,d6
- bne GNI_Wback
- lea idfield,a0
- move.b (a0)+,d6
- GNI_Wback
- move.l a0,IDTPtr
- move.w #$BE51,d5
- jsr wbyte
- move.w stack,d5
- jsr gword
- add.w #2,stack
- move.w d6,sPC
- jsr calcpca
- or.w #1,sF
- rts
-
- HandleSector:
- move.w #$BE74,d5
- jsr gword
- move.w d6,sHL
- rol.w #8,d6
- cmp.b #$45,d6
- beq WriteSector
- move.w #$C67f,sPC
- jmp calcpca
-
- WriteSector:
- move.w #$BE62,d5
- jsr gword
- move.w d6,d5
- lea DiskBuf,a0
- move.w #511,d7
- WSC_Loop
- move.l a0,-(sp)
- jsr gbyte
- move.l (sp)+,a0
- move.b d6,(a0)+
- add.w #1,d5
- dbf.b d7,WSC_Loop
-
- movem.l d0-d7/a0-a6,-(sp)
- lea idfield,a0
- move.l trackoffs,d0
- add.l #66,d0
- WSC_Loop1
- cmp.b #$FF,(a0)
- beq WSC_Erreur
- cmp.b (a0)+,sHL
- beq WSC_found
- add.l #512,d0
- bra WSC_Loop1
- WSC_found
- move.l fhandle,d1
- move.l d0,d2
- moveq.l #-1,d3
- move.l dosbase,a6
- jsr _Seek(a6)
- move.l fhandle,d1
- move.l #DiskBuf,d2
- move.l #512,d3
- jsr _Write(a6)
- movem.l (sp)+,d0-d7/a0-a6
- move.w stack,d5
- jsr gword
- add.w #2,stack
- move.w d6,sPC
- jsr calcpca
- or.w #1,sF
- rts
-
- WSC_Erreur
- and.w #$FE,sF
- movem.l (sp)+,d0-d7/a0-a6
- move.w stack,d5
- jsr gword
- add.w #2,stack
- move.w d6,sPC
- jsr calcpca
- rts
-
- ReadSector:
- RSec_ctd
- movem.l d0-d7/a0-a6,-(sp)
- lea idfield,a0
- move.l trackoffs,d0
- add.l #66,d0
- RSC_Loop1
- cmp.b #$FF,(a0)
- beq RSC_Erreur
- cmp.b (a0)+,sHL
- beq RSC_found
- add.l #512,d0
- bra RSC_Loop1
- RSC_found
- move.l fhandle,d1
- move.l d0,d2
- moveq.l #-1,d3
- move.l dosbase,a6
- jsr _Seek(a6)
- move.l fhandle,d1
- move.l #DiskBuf,d2
- move.l #512,d3
- jsr _Read(a6)
- movem.l (sp)+,d0-d7/a0-a6
-
- move.w #$BE62,d5
- jsr gword
- move.w d6,d5
- lea DiskBuf,a0
- move.w #511,d7
- RSC_Loop
- move.b (a0)+,d6
- move.l a0,-(sp)
- jsr wbyte
- move.l (sp)+,a0
- addq.w #1,d5
- dbf.b d7,RSC_Loop
- move.w d5,sHL
- or.w #1,sF
- move.w #$C6C8,sPC
- move.w #$FB7E,sBC
- jsr calcpca
- rts
-
- RSC_Erreur
- and.w #$FE,sF
- movem.l (sp)+,d0-d7/a0-a6
- move.w stack,d5
- jsr gword
- add.w #2,stack
- move.w d6,sPC
- jsr calcpca
- rts
-
- END
-