Skip to content

Commit

Permalink
added resload_ReadJoyPort capability from whdload v19
Browse files Browse the repository at this point in the history
  • Loading branch information
jotd666 committed Oct 9, 2024
1 parent ec8887d commit 97e8b29
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 11 deletions.
Binary file modified bin/jst
Binary file not shown.
1 change: 1 addition & 0 deletions docs/bugs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
General:

- resload_ReadJoyPort limitations: 1) not cached against multiple quick reads and 2) mouse not supported (yet?)
- address error (and possibly others like illegal instruction...) are forwarded to the program instead of
being intercepted by JST exception layer in relocated VBR (ex: Universe: g 1 => universe custom guru screen)
- add NoMemReverse (not very useful)
Expand Down
5 changes: 5 additions & 0 deletions docs/history.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v7.4 (08.10.2024)

- supports whdload v19 ReadJoyPort API (to some extent)
- fixed potential memory cleanup issue with kick 1.3 (thanks Peter Pettersson)

v7.3 (07.02.2023)

- can load whdload slaves containing debug symbols, like Turrican 2 AGA
Expand Down
15 changes: 8 additions & 7 deletions src/ReadJoypad.s
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
BITDEF JP,BTN_RED,$16
BITDEF JP,BTN_BLU,$17


POTGO_RESET = $FF00 ; was $FFFF but changed, thanks to robinsonb5@eab

; optional call to differentiate 2-button joystick from CD32 joypad
Expand Down Expand Up @@ -91,20 +92,20 @@ _detect_controller_types:
rts
.do_detect
moveq #0,d0
bsr .detect
bsr _detect_a_controller
; ignore first read
bsr .wvbl
moveq #0,d0
bsr .detect
bsr _detect_a_controller

lea controller_joypad_0(pc),a0
move.b D0,(A0)

bsr .wvbl

moveq #1,d0
bsr .detect
lea controller_joypad_1(pc),a0
bsr _detect_a_controller
lea controller_joypad_0+1(pc),a0
move.b D0,(A0)
rts

Expand All @@ -117,7 +118,8 @@ _detect_controller_types:
btst #5,d0
beq.b .wait
rts
.detect

_detect_a_controller:
movem.l d1-d6/a0-a1,-(a7)

tst.l d0
Expand Down Expand Up @@ -218,7 +220,7 @@ _read_joystick:
moveq #14,d4 ; blue button ( port 1 )
move.w #$6f00,d5 ; for potgo port 1
moveq #joy1dat,d6 ; port 1
move.b controller_joypad_1(pc),d2
move.b controller_joypad_0+1(pc),d2

.direction
lea $DFF000,a0
Expand Down Expand Up @@ -325,7 +327,6 @@ joy0 dc.l 0
joy1 dc.l 0
controller_joypad_0:
dc.b $FF ; set: joystick 0 is a joypad, else joystick
controller_joypad_1:
dc.b $FF
detected_by_os
dc.b 0
55 changes: 52 additions & 3 deletions src/jst_whd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,28 @@ fake_resload:
;Get the string which has been specified via the Custom/S option.
; The buffer is filled as far as possible. If buffer was not large
; enough false will be returned.

DEF_WHDOFFSET resload_VSNPrintF
; format string like clib.vsnprintf/exec.RawDoFmt (84)
; IN: d0 = ULONG length of buffer
; a0 = APTR buffer to fill
; a1 = CPTR format string
; a2 = APTR argument array
; OUT: d0 = ULONG length of created string with unlimited
; buffer without final '\0'
; a0 = APTR pointer to final '\0'

DEF_WHDOFFSET resload_Log
; write log message (88)
; IN: a0 = CSTR format string
; (4,a7) = LABEL argument array
; OUT: -

;******* the following functions require ws_Version >= 19

DEF_WHDOFFSET resload_ReadJoyPort
; return the state of the selected joy/mouse port (8c)
; IN: d0 = ULONG port/flags
; OUT: d0 = ULONG state

fake_resload_end:

Expand Down Expand Up @@ -475,6 +496,33 @@ jst_resload_Examine

jst_resload_ExNext
WHDLOAD_UNSUPPORTED_CALL WHD_ExNext,"ExNext"
jst_resload_Log:
WHDLOAD_UNSUPPORTED_CALL WHD_Log,"Log"
jst_resload_VSNPrintF:
WHDLOAD_UNSUPPORTED_CALL WHD_VSNPrintF,"VSNPrintF"

jst_resload_ReadJoyPort:
movem.l d1-d2/a0,-(a7)
move.w d0,d1
and.w #1,d1 ; port
lea controller_joypad_0(pc),a0

btst #31,d0 ; RJP_Detect
beq.b .1
; detect controllers and update status
bsr _detect_a_controller
move.b d0,(a0,d1.w)
.1
move.l #RJP_TYPE_GAMECTRL,d2
tst.b (a0,d1.w)
bne.b .2
move.l #RJP_TYPE_JOYSTK,d2
.2
move.l d1,d0
bsr _read_joystick
or.l d2,d0
movem.l (a7)+,d1-d2/a0
rts

jst_resload_GetCustom:
STORE_REGS D1/A1/A4
Expand Down Expand Up @@ -963,12 +1011,12 @@ jst_resload_Control:
.sk12
cmp.l #WHDLTAG_VERSION_GET,D0 ;get WHDLoad major version number
bne.b .sk13
move.l #18,D0 ; highest possible
move.l #19,D0 ; highest possible
bra.b .storetag
.sk13
cmp.l #WHDLTAG_REVISION_GET,D0 ;get WHDLoad major version number
bne.b .sk14
moveq.l #2,D0 ; highest possible
moveq.l #0,D0 ; highest possible
bra .storetag
.storetag:
move.l D0,(A0)+
Expand Down Expand Up @@ -1649,6 +1697,7 @@ WHD_OsEmuFail:
lea WHDMessAbort(pc),A5
bra RTStoreMessage


; cdio eats a lot of stack, not suitable for all games
; this stack is shared by RN decruncher, same issue (when game files are packed)
ds.b WHD_STACK_SIZE,0
Expand Down
2 changes: 1 addition & 1 deletion src/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3
7.4

0 comments on commit 97e8b29

Please sign in to comment.