@@ 13,13 13,6 @@ Application: MACRO
;
Application_Main:
- ld hl,DOS_Terminate
- call System_SetTerminateHandler
-
- call DOS_IsDOS2
- ld hl,Application_dos2RequiredError
- jp c,System_TerminateWithError
-
call Application_CheckStack
call VDP_InitMirrorsOnVDPUpgrades
@@ 27,8 20,6 @@ Application_Main:
ld hl,Application_welcome
call System_Print
- ld ix,Mapper_instance
- call Mapper_Construct
ld ix,Heap_main
call Heap_Construct
@@ 37,25 28,13 @@ Application_Main:
ld ix,Application_instance
call Application_Construct
- ld de,Application_Abort
- call DOS_DefineAbortExitRoutine
- call Application_EnterMainLoop
- call Application_Abort
- ret
+ push ix
+ ld hl,Application_EnterMainLoop
+ call System_TryCall
+ pop ix
+ call Application_Destruct
-; DOS error or abort handler
-Application_Abort:
- push af
- push bc
- ld ix,Mapper_instance
- call Mapper_RestoreInitialState
- ld ix,Application_instance
- call Application_Destruct
- ld ix,Mapper_instance
- call Mapper_Destruct
- call Application_ExitBlackout
- pop bc
- pop af
+ call System_Rethrow
ret
; ix = this
@@ 117,7 96,12 @@ Application_GetSynthesizer:
Application_EnterMainLoop:
call Application_ParseCLI
call Application_EnterBlackout
- call Application_Play
+ push ix
+ ld hl,Application_Play
+ call System_TryCall
+ pop ix
+ call Application_ExitBlackout
+ call System_Rethrow
ret
; ix = this
@@ 129,7 113,7 @@ Application_ParseCLI:
; ld a,l
; or h
; ld hl,Application_usageInstructions
-; jp z,System_TerminateWithError
+; jp z,System_ThrowExceptionWithMessage
pop ix
ret
@@ 169,30 153,14 @@ Application_CheckStack:
ld hl,-(HEAP + HEAP_SIZE + STACK_SIZE)
add hl,sp
ld hl,Application_insufficientTPAError
- jp nc,System_TerminateWithError
+ jp nc,System_ThrowExceptionWithMessage
ret
-; a = DOS error code
-Application_CheckDOSError:
- and a
- ret z
-Application_TerminateWithDOSError:
- ld b,a
- ld de,Application_explainBuffer
- call DOS_ExplainErrorCode
- ld hl,Application_explainBuffer
- call System_Print
- call System_PrintCrLf
- jp System_TerminateWithError
-
;
SECTION RAM
Application_instance: Application
-Application_explainBuffer:
- ds 64,0
-
ENDS
Application_welcome:
@@ 201,9 169,6 @@ Application_welcome:
Application_listening:
db "Listening...",13,10,0
-Application_dos2RequiredError:
- db "MSX-DOS 2 is required.",13,10,0
-
Application_insufficientTPAError:
db "Insufficient TPA space.",13,10,0
@@ 74,7 74,7 @@ CLI_ParseOption: PROC
cp "B"
jr z,OptionBlackout
ld hl,CLI_unknownOptionError
- jp System_TerminateWithError
+ jp System_ThrowExceptionWithMessage
OptionBlackout:
ld (ix + CLI.blackout),-1
inc de
@@ 86,7 86,7 @@ Next:
cp " "
ret z
ld hl,CLI_unknownOptionError
- jp System_TerminateWithError
+ jp System_ThrowExceptionWithMessage
ENDP
; de = buffer position
@@ 95,7 95,7 @@ CLI_ParsePath:
ld a,(ix + CLI.path)
or (ix + CLI.path + 1)
ld hl,CLI_multiplePathsError
- jp nz,System_TerminateWithError
+ jp nz,System_ThrowExceptionWithMessage
ld (ix + CLI.path),e
ld (ix + CLI.path + 1),d
call DOS_ParsePathname
@@ 23,11 23,7 @@ RAM: equ RAM_PAGE1
SECTION TPA
-;
-; Program entry point
-;
-COM_Main:
- jp Application_Main
+ DOS2Runtime Application_Main
INCLUDE "DOS.asm"
INCLUDE "BIOS.asm"
@@ 35,11 31,11 @@ COM_Main:
INCLUDE "System.asm"
INCLUDE "Memory.asm"
INCLUDE "MemoryTest.asm"
- INCLUDE "Mapper.asm"
INCLUDE "Heap.asm"
INCLUDE "HeapTest.asm"
INCLUDE "Math.asm"
INCLUDE "VDP.asm"
+ INCLUDE "DOS2Runtime.asm"
INCLUDE "Application.asm"
INCLUDE "CLI.asm"
INCLUDE "Hook.asm"