home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Brotikasten
/
BROTCD01.iso
/
amiga
/
frodov13.lha
/
src
/
Main.asm
< prev
next >
Wrap
Assembly Source File
|
1995-02-22
|
35KB
|
1,700 lines
*
* Main.asm - Hauptprogramm des C64-Emulators/Einstellungsfenster
*
* Copyright (C) 1994-1995 by Christian Bauer
*
MACHINE 68020
INCLUDE "exec/types.i"
INCLUDE "exec/macros.i"
INCLUDE "exec/memory.i"
INCLUDE "exec/execbase.i"
INCLUDE "dos/dos.i"
INCLUDE "intuition/intuition.i"
INCLUDE "graphics/displayinfo.i"
INCLUDE "libraries/gadtools.i"
INCLUDE "libraries/asl.i"
INCLUDE "libraries/locale.i"
INCLUDE "libraries/cybergraphics.i"
INCLUDE "workbench/workbench.i"
INCLUDE "FrodoPrefs.i"
INCLUDE "Frodo_rev.i"
CATCOMP_NUMBERS = 1
INCLUDE "Strings.i"
XREF _SysBase ;Startup
XREF _DOSBase
XDEF _main
XDEF _UtilityBase
XDEF _IntuitionBase
XDEF _GfxBase
XDEF _GadToolsBase
XDEF _AslBase
XDEF _EGSBase
XDEF _VilIntuiBase
XDEF _CyberGfxBase
XDEF _CiaBase
XDEF _MiscBase
XDEF _SID6581Base
XDEF ShowPrefs
XREF PrefsNGads
XDEF MainTask
XDEF TheLocale ;Strings.o
XREF GetString
XREF TheRAM ;6510.asm
XREF TheBasic
XREF TheKernal
XREF TheChar
XREF TheColor
XREF Init6510
XREF Start6510
XREF Stop6510
XREF Wait6510
XREF Pause6510
XREF Resume6510
XREF Localize6510
XREF Reset6526 ;6526.asm
XREF ChangedKeys
XREF CIACycles
XREF Joystick1On
XREF Joystick2On
XREF JoystickSwap
XREF KeyboardYZ
XREF OpenGraphics ;6569.asm
XREF CloseGraphics
XREF WaitForClick
XREF AmigaToFront
XREF EmulToFront
XREF DisplayID
XREF ScreenType
XREF NormalCycles
XREF BadLineCycles
XREF Collisions
XREF Overscan
XREF SkipLatch
XREF Reset6581 ;6581.asm
XREF ChangedSID
XREF PauseSound
XREF ResumeSound
XREF CloseSID
XREF UseSIDCard
XREF Open1541 ;1541.asm
XREF Close1541
XREF ChangedDirs
XREF CloseIEC
XREF ChangedIEC
XREF Dir8
XREF Dir9
XREF Dir10
XREF Dir11
XREF Drv8IsIEC
XREF Drv9IsIEC
XREF Drv10IsIEC
XREF Drv11IsIEC
XREF OtherIEC
XREF MapSlash
SECTION "CODE",CODE
**
** Definitionen
**
; CyberGfx
CModeRequest = -66
**
** Makros
**
; LongInt-Wert aus Integer-Gadget a0 lesen
GetInt MACRO ;Ziel
move.l gg_SpecialInfo(a0),a0
move.l si_LongInt(a0),\1
ENDM
**
** Hauptprogramm
**
; Task holen
_main move.l _SysBase,a6
sub.l a1,a1
JSRLIB FindTask
move.l d0,MainTask
; Libraries ÷ffnen
moveq #37,d0
lea UtilityName,a1
JSRLIB OpenLibrary
move.l d0,_UtilityBase
beq NoUtility
moveq #37,d0
lea IntuiName,a1
JSRLIB OpenLibrary
move.l d0,_IntuitionBase
beq NoIntui
moveq #37,d0
lea GfxName,a1
JSRLIB OpenLibrary
move.l d0,_GfxBase
beq NoGfx
moveq #37,d0
lea GadToolsName,a1
JSRLIB OpenLibrary
move.l d0,_GadToolsBase
beq NoGadTools
moveq #38,d0
lea AslName,a1
JSRLIB OpenLibrary
move.l d0,_AslBase
beq NoAsl
moveq #37,d0
lea IconName,a1
JSRLIB OpenLibrary
move.l d0,_IconBase
beq NoIcon
moveq #0,d0
lea SID6581Name,a1
JSRLIB OpenLibrary
move.l d0,_SID6581Base
lea CiaResName,a1
JSRLIB OpenResource
move.l d0,_CiaBase
beq NoCiaRes
lea MiscResName,a1
JSRLIB OpenResource
move.l d0,_MiscBase
beq NoMiscRes
; Locale ÷ffnen und Catalog laden
move.l _SysBase,a6
moveq #37,d0
lea LocaleName,a1
JSRLIB OpenLibrary
move.l d0,_LocaleBase
beq 1$
move.l d0,a6
sub.l a0,a0
lea CatalogName,a1
sub.l a2,a2
JSRLIB OpenCatalogA
move.l d0,TheCatalog
; Datenstrukturen lokalisieren
1$ bsr Localize
bsr Localize6510
; 68020 vorhanden?
move.l _SysBase,a0
move.w AttnFlags(a0),d0
btst #AFB_68020,d0
beq No68020Exit
; ScreenMode- und Directory-Requester holen
move.l _AslBase,a6
moveq #ASL_ScreenModeRequest,d0
lea ScreenReqTags,a0
JSRLIB AllocAslRequest
move.l d0,ScreenRequester
beq NoMemExit
moveq #ASL_FileRequest,d0
lea DirReqTags,a0
JSRLIB AllocAslRequest
move.l d0,DirRequester
beq NoMemExit
; Vorgegebene Einstellungen
move.w #63,PNormalCycles
move.w #23,PBadLineCycles
move.w #63,PCIACycles
clr.w PJoystick1On
move.w #-1,PJoystick2On
clr.w PJoystickSwap
clr.l PDisplayID
clr.w PScreenType
clr.b PDir8
clr.b PDir9
clr.b PDir10
clr.b PDir11
clr.w PUseSIDCard
clr.w KeyboardYZ
move.w #-1,PCollisions
move.w #-1,PMapSlash
move.w #-1,PFastReset
move.w #OSCAN_TEXT,POverscan
move.w #1,PSkipLatch
; Einstellungen laden
move.l _DOSBase,a6
move.l #PrefsFileName,d1
move.l #MODE_OLDFILE,d2
JSRLIB Open
move.l d0,d7
beq NoEmulPrefs
move.l d7,d1
move.l #ThePrefs,d2
move.l #PrefsLength,d3
JSRLIB Read
move.l d7,d1
JSRLIB Close
NoEmulPrefs
; Einstellungsfenster darstellen
clr.w PrefsFromEmul
bsr DoThePrefs
; Einstellungen ⁿbernehmen, wenn OK geklickt, sonst beenden
tst.l d7
beq Exit
bsr SetPrefs
; Dateikram vorbereiten
jsr Open1541
jsr ChangedIEC
bsr IECErrorReq
; Speicher fⁿr alles holen (die unteren Worte mⁿssen mit den C64-Adressen
; ⁿbereinstimmen, au▀er CharROM)
move.l _SysBase,a6
move.l #$30000,d0 ;192K
move.l #MEMF_ANY|MEMF_CLEAR,d1
JSRLIB AllocVec
move.l d0,RAMBlock
beq NoMemExit
add.l #$ffff,d0 ;Auf xxxx0000 bringen
clr.w d0
move.l d0,TheRAM
add.l #$11000,d0
move.l d0,TheChar ;yyyy1000
add.l #$9000,d0
move.l d0,TheBasic ;yyyya000
add.l #$3800,d0
move.l d0,TheColor ;yyyyd800
add.l #$0800,d0
move.l d0,TheKernal ;yyyye000
; Opcodes $22 (undefiniert) ab $10000 installieren,
; fⁿr den Fall, da▀ ein Programm den Wraparound bei $ffff macht
move.l TheRAM,a0
lea $10000(a0),a0
moveq #256/4-1,d0
1$ move.l #$22222222,(a0)+
dbra d0,1$
; ROMs laden
move.l _DOSBase,a6
move.l #BasicFileName,d1 ;Basic
move.l #MODE_OLDFILE,d2
JSRLIB Open
move.l d0,d7
beq NoBasicExit
move.l d0,d1
move.l TheBasic,d2
move.l #$2000,d3
JSRLIB Read
move.l d7,d1
JSRLIB Close
move.l #KernalFileName,d1 ;Kernal
move.l #MODE_OLDFILE,d2
JSRLIB Open
move.l d0,d7
beq NoKernalExit
move.l d0,d1
move.l TheKernal,d2
move.l #$2000,d3
JSRLIB Read
move.l d7,d1
JSRLIB Close
move.l #CharFileName,d1 ;Char
move.l #MODE_OLDFILE,d2
JSRLIB Open
move.l d0,d7
beq NoCharExit
move.l d0,d1
move.l TheChar,d2
move.l #$1000,d3
JSRLIB Read
move.l d7,d1
JSRLIB Close
; Betriebssystem patchen
move.l TheKernal,a0
move.w #$f200,$0d40(a0) ;IECOut
move.w #$f201,$0d23(a0) ;IECOutATN
move.w #$f202,$0d36(a0) ;IECOutSec
move.w #$f203,$0e13(a0) ;IECIn
move.w #$f204,$0def(a0) ;IECSetATN
move.w #$f205,$0dbe(a0) ;IECRelATN
move.w #$f206,$0dcc(a0) ;IECTurnaround
move.w #$f207,$0e03(a0) ;IECRelease
bsr PatchReset
; Bildschirm ÷ffnen
jsr OpenGraphics
cmp.l #1,d0
beq NoScreenExit
cmp.l #2,d0
beq NoMemExit
cmp.l #3,d0
beq NoEGSExit
cmp.l #4,d0
beq NoVilIntuiExit
cmp.l #5,d0
beq NoDisplayIDExit
cmp.l #6,d0
beq ScrTooSmallExit
cmp.l #7,d0
beq NoCyberGfxExit
cmp.l #8,d0
beq NoCyberModeExit
; Alles initialisieren
jsr Reset6526
jsr Reset6581
jsr Init6510
; 6510 starten
jsr Start6510
tst.l d0
bne NoMemExit
; Auf Mausklick warten
jsr WaitForClick
; Programm beenden
bra Exit
*
* Fehlerbehandlung/Beenden
*
MACHINE 68000
No68020Exit moveq #MSG_NO68020,d0
lea TheLocale,a0
jsr GetString
lea ErrorReq,a1
move.l d0,es_TextFormat(a1)
sub.l a0,a0
sub.l a2,a2
sub.l a3,a3
move.l _IntuitionBase,a6
JSRLIB EasyRequestArgs
bra NoCiaRes
MACHINE 68020
NoMemExit moveq #MSG_NOMEM,d0
bra ReqExit
NoScreenExit moveq #MSG_NOSCREEN,d0
bra ReqExit
NoEGSExit moveq #MSG_NOEGS,d0
bra ReqExit
NoVilIntuiExit moveq #MSG_NOVILINTUI,d0
bra ReqExit
NoCyberGfxExit moveq #MSG_NOCYBERGFX,d0
bra ReqExit
NoDisplayIDExit moveq #MSG_NODISPLAYID,d0
bra ReqExit
NoCyberModeExit moveq #MSG_NOCYBERMODE,d0
bra ReqExit
ScrTooSmallExit moveq #MSG_SCRTOOSMALL,d0
bra ReqExit
NoKernalExit moveq #MSG_NOKERNAL,d0
bra ReqExit
NoBasicExit moveq #MSG_NOBASIC,d0
bra ReqExit
NoCharExit moveq #MSG_NOCHAR,d0
ReqExit lea TheLocale,a0
jsr GetString
lea ErrorReq,a1
move.l d0,es_TextFormat(a1)
sub.l a0,a0
sub.l a2,a2
sub.l a3,a3
move.l _IntuitionBase,a6
JSRLIB EasyRequestArgs
Exit jsr Stop6510
jsr Reset6581 ;Stoppt diesen LΣrm!
jsr CloseSID
jsr CloseGraphics
jsr CloseIEC
jsr Close1541
move.l _SysBase,a6