MrDave Posted February 8, 2023 Share Posted February 8, 2023 (edited) Does anyone have advice on joystick reading ? I tried a call %1105 Followed by a call &1feb. I dont see any activity on on table pointed to by Ix.. i think i am missing something in the init Edited February 8, 2023 by MrDave Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted February 8, 2023 Share Posted February 8, 2023 To read the joystick I use the following wrapper methods: CONTROLLER_INIT: EQU $1105 CONTROLLER_SCAN: EQU $1f76 DECODER: EQU $1f79 POLLER: EQU $1feb ; To be added together for CONTROLLER_MAP +0 (player 1), ; and +1 (player 2) CONTROLLER_ENABLE: EQU 80h KEYPAD_ENABLE: EQU 10h ARM_BUTTON_ENABLE: EQU 8 JOYSTICK_ENABLE: EQU 2 FIRE_BUTTON_ENABLE: EQU 1 ; ; Controller Table offsets PLAYER1: EQU 0 ; Settings (above) PLAYER2: EQU 1 FIRE1: EQU 2 ; Fire button 1 (40h=yes, 0=no) JOY1: EQU 3 ; 1=N, 2=E, 4=S, 8=W, etc. SPIN1: EQU 4 ; counter ARM1: EQU 5 ; Arm button 1 (40h=yes, 0=no) KEYPAD1: EQU 6 ; 0-9, '*'=10, '#'=11 FIRE2: EQU 7 JOY2: EQU 8 SPIN2: EQU 9 ARM2: EQU 10 KEYPAD2: EQU 11 ; Test for the press of a joystick button (0 or 1) ; A = 255 - fire button pressed JOYTST: LD A,(CONTROLLER_BUFFER+FIRE1) OR A JR Z,JOYTST2 LD A,255 RET JOYTST2: LD A,(CONTROLLER_BUFFER+5) AND 040h RET Z LD A,255 RET ; Test for a press of a keypad button JOYPAD: LD A,(CONTROLLER_BUFFER+KEYPAD1) RET ; ; Test for the direction of joystick 0 ; Result: A JOYDIR: LD A,(CONTROLLER_BUFFER+JOY1) RET CONTROLLER_BUFFER: DS 12 ; Pointer to hand controller input area Before using you need to call CONTROLLER_INIT ; Enable both joysticks, buttons, keypads LD HL,09b9bh LD (CONTROLLER_BUFFER),HL XOR A CALL CONTROLLER_INIT And before your section of code where you want to read joystick inputs, call POLLER e.g. CALL POLLER CALL JOYDIR ; A now has the joystick direction Important notes: - The CONTROLLER_BUFFER needs to be pointed to in your cartridge header e.g. ; ; Set ROM header ORG 8000h ; -------------------------------------------- ; DB 0AAh,055h ;Cartridge present: Colecovision logo DB 055h,0AAh ;Cartridge present: skip logo, Colecovision logo DW 0000 ;Pointer to the sprite name table DW 0000 ;Pointer to the sprite order table DW 0000 ;Pointer to the working buffer for WR_SPR_NM_TBL DW CONTROLLER_BUFFER ;Pointer to the hand controller input areas DW START ;Entry point to the user program ;**************************************************************** Make sure you also clear out the buffer before using it. Quote Link to comment Share on other sites More sharing options...
MrDave Posted February 8, 2023 Author Share Posted February 8, 2023 (edited) Thanks ! I am reading your book on kindle lol.. So do i need to clear buffer before each read ? Also the ld hl, 09b9bh is that just &9B9B ? Edited February 8, 2023 by MrDave Quote Link to comment Share on other sites More sharing options...
MrDave Posted February 8, 2023 Author Share Posted February 8, 2023 Also.. are there hardcopy's of your books ? Thanks Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted February 8, 2023 Share Posted February 8, 2023 5 minutes ago, MrDave said: Thanks ! I am reading your book on kindle lol.. So do i need to clear buffer before each read ? Also the ld hl, 09b9bh is that just &9B9B ? So no just clear the buffer once at start-up before you call CONTROLLER_INIT, then call POLLER and then one of the helper functions. Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted February 8, 2023 Share Posted February 8, 2023 2 minutes ago, MrDave said: Also.. are there hardcopy's of your books ? Thanks Cote Gamers have sold out of the spiral print edition, although I do have a small number of signed copies (here in OZ so post can be a bit steep due to the book being 1.1kgs - see my website). I am going to do a re-edit (as with controllers especially there are a couple of discoveries to ensure your game works on all platforms i.e. Phoenix) and release a new edition which I will release as an Amazon Print on Demand version, they now have hard back as a print option. I am working on another book at the moment though, so it will be a few months before I get that done. Completely re-written version of the Sprite and Tile editor will be coming out as well. 2 Quote Link to comment Share on other sites More sharing options...
MrDave Posted February 9, 2023 Author Share Posted February 9, 2023 Looking foward to your books...i stillcant read joys yet.. I put hl, &9B9B Then call init Then call poll.. But nothing in buffer... I put buffer address in header ( ram &7050 ) as test Still drawing a blank Quote Link to comment Share on other sites More sharing options...
MrDave Posted February 9, 2023 Author Share Posted February 9, 2023 (edited) Ok deeper reading in your book ..i have it working.. I fixed the load 9b before the init i saw from the book that the 9B 's must stay in the buffer... works great now.. thanks Edited February 9, 2023 by MrDave 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.