From 9747e0ecc003dfa661c2c1966ccb0b652d6a01a7 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Sun, 29 May 2016 09:55:42 +1000 Subject: [PATCH] First pass at workbench compatible version --- 028.bs/Makefile | 6 +++-- 028.bs/disk.s | 16 ++++++++++-- 028.bs/game1.s | 57 +++++++++++++++++++++++++++++++++++++--- 028.bs/wbstartup.i | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 028.bs/wbstartup.i diff --git a/028.bs/Makefile b/028.bs/Makefile index 6283d84..bd127e9 100644 --- a/028.bs/Makefile +++ b/028.bs/Makefile @@ -1,3 +1,4 @@ +TRACKLOADER=1 EXAMPLE_NAME=game1 BACKGROUND_COLOR=09e BACKGROUND_GREY_COLOR=777 @@ -81,7 +82,7 @@ IMAGES=foreground.png \ IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin)) -VASM_EXTRA_ARGS=-DSFX=1 -DMAX_P61_SIZE=$(MAX_P61_SIZE) -allmp +VASM_EXTRA_ARGS=-DSFX=1 -DMAX_P61_SIZE=$(MAX_P61_SIZE) -allmp -DTRACKLOADER=$(TRACKLOADER) LINKER_OPTIONS=-T link.script.x @@ -296,4 +297,5 @@ out/main.o: $(IMAGEDATA) \ out/panelFade.s out/jump.raw out/falling.raw out/chaching.raw out/whoosh.raw out/yay.raw - +out/main.exe: out/main.o $(OBJS) + vlink -hunkattr DATA=2 -hunkattr CODE=2 -hunkattr .text=2 -hunkattr .code=2 -hunkattr .data=2 -hunkattr .noload=2 -hunkattr .bss=2 $< $(OBJS) -o $@ \ No newline at end of file diff --git a/028.bs/disk.s b/028.bs/disk.s index b763365..a36c046 100644 --- a/028.bs/disk.s +++ b/028.bs/disk.s @@ -1,10 +1,12 @@ xdef LoadDiskData - + + LoadDiskData: ;; a0 - destination address ;; a1 - start address ;; d0 - size movem.l d0-a6,-(sp) + if TRACKLOADER=1 lea $dff002,a6 ; LoadMFMB uses this custom base addr move.l d0,d1 @@ -22,6 +24,16 @@ LoadDiskData: lsr.l #3,d1 neg.w d1 jsr LoadMFMB ; load the data! - + else + + lsr.l #2,d0 + sub.l #1,d0 +.loop: + move.l (a1)+,(a0)+ + dbra d0,.loop + + endif movem.l (sp)+,d0-a6 + + rts diff --git a/028.bs/game1.s b/028.bs/game1.s index 46d1293..f2bf58d 100644 --- a/028.bs/game1.s +++ b/028.bs/game1.s @@ -36,24 +36,43 @@ xdef levelInstallers xdef tutorialLevelInstallers + if TRACKLOADER=1 byteMap: dc.l Entry dc.l endCode-byteMap + endif Entry: + if TRACKLOADER=0 + jmp StartupFromOS +Entry2: lea userstack,a7 + endif + lea CUSTOM,a6 move #$7ff,DMACON(a6) ; disable all dma move #$7fff,INTENA(a6) ; disable all interrupts + jsr WaitVerticalBlank + + move.w #$7FFF,d0 + move.w d0,$9A(a6) ; Disable Interrupts + move.w d0,$96(a6) ; Clear all DMA channels + move.w d0,$9C(a6) ; Clear all INT requests + move.w d0,$9C(a6) ; Clear all INT requests + + move.w #$0C00,$106(a6) ;BPLCON3 + move.w #$0011,$10C(a6) ;BPLCON4 + lea Level3InterruptHandler,a3 move.l a3,LVL3_INT_VECTOR move.w #0,d0 jsr StartMusic jsr ShowSplash + MainMenu: jsr ShowMenu @@ -829,6 +848,36 @@ BlitCountdown: move.l a1,BLTDPTH(a6) ;destination top left corner move.w #(12*PANEL_BIT_DEPTH)<<6|(COUNTDOWN_BLIT_WIDTH_WORDS),BLTSIZE(a6) rts + + if TRACKLOADER=0 +; from Photon http://coppershade.org/asmskool/SOURCES/Developing-Demo-Effects/DDE2/Coppershade-DDE2/PhotonsMiniWrapper1.04!.S +StartupFromOS: + move.l 4.w,a6 ;Exec library base address in a6 + sub.l a4,a4 + btst #0,297(a6) ;68000 CPU? + beq.s .yes68k + lea .GetVBR(pc),a5 ;else fetch vector base address to a4: + jsr -30(a6) ;enter Supervisor mode + ;; *--- save view+coppers ---* +.yes68k: + lea .GfxLib(pc),a1 ;either way return to here and open + jsr -408(a6) ;graphics library + tst.l d0 ;if not OK, + beq.s .quit ;exit program. + move.l d0,a5 ;a5=gfxbase + move.l a5,a6 + move.l 34(a6),-(sp) + sub.l a1,a1 ;blank screen to trigger screen switch + jsr -222(a6) ;on Amigas with graphics cards + jmp Entry2 + +.quit: moveq #0,d0 ;clear error return code to OS + rts + +.GfxLib:dc.b "graphics.library",0,0 +.GetVBR:dc.w $4e7a,$c801 ;hex for "movec VBR,a4" + rte + endif ;; variable prefix ;; level name @@ -987,13 +1036,13 @@ nextLevelInstaller: tutorialLevelInstallers: dc.l InstallLevel91 -endTutorialLevelInstaller: dc.l InstallLevel92 dc.l InstallLevel93 dc.l InstallLevel94 dc.l InstallLevel95 dc.l InstallLevel96 dc.l InstallLevel97 +endTutorialLevelInstaller: dc.l 0 panelFade: include "out/panelFade.s" @@ -1065,9 +1114,11 @@ livesCounterShortText: stopScrollingPending: dc.w 0 freezeCountdownCounter: - dc.w 0 + dc.w 0 + if TRACKLOADER=0 startUserstack: ds.b $1000 ; size of stack userstack: - + endif + end \ No newline at end of file diff --git a/028.bs/wbstartup.i b/028.bs/wbstartup.i new file mode 100644 index 0000000..89b3a6a --- /dev/null +++ b/028.bs/wbstartup.i @@ -0,0 +1,65 @@ + + IFND EXEC_EXEC_I + include "exec/exec.i" + ENDC + IFND LIBRARIES_DOSEXTENS_I + include "libraries/dosextens.i" + ENDC + + +_LVOForbid EQU -132 +_LVOFindTask EQU -294 +_LVOGetMsg EQU -372 +_LVOReplyMsg EQU -378 +_LVOWaitPort EQU -384 + + movem.l d0/a0,-(sp) save initial values + clr.l returnMsg + + sub.l a1,a1 + move.l 4.w,a6 + jsr _LVOFindTask(a6) find us + move.l d0,a4 + + tst.l pr_CLI(a4) + beq.s fromWorkbench + + * we were called from the CLI + movem.l (sp)+,d0/a0 restore regs + bra end_startup and run the user prog + + * we were called from the Workbench +fromWorkbench: + lea pr_MsgPort(a4),a0 + move.l 4.w,a6 + jsr _LVOWaitPort(A6) wait for a message + lea pr_MsgPort(a4),a0 + jsr _LVOGetMsg(A6) then get it + move.l d0,returnMsg save it for later reply + + * do some other stuff here RSN like the command line etc + nop + + movem.l (sp)+,d0/a0 restore +end_startup: + bsr.s Entry call our program + + * returns to here with exit code in d0 + move.l d0,-(sp) save it + + tst.l returnMsg + beq.s exitToDOS if I was a CLI + + move.l 4.w,a6 + jsr _LVOForbid(a6) + + move.l returnMsg(pc),a1 + jsr _LVOReplyMsg(a6) + +exitToDOS: + move.l (sp)+,d0 exit code + rts + + * startup code variable +returnMsg: dc.l 0 +