576XE Posted June 16, 2016 Share Posted June 16, 2016 Hello friends! (ATARI LOVES YOU!)This is the code converted from MAC/65 tokens to ATMASII source.It's well known algorithmus for converting STM1-mouse GrayCode into PM movement commands and it's work.IT USES: TIMER for reading and deciphering Gray-Code to mouse data PMG for drawing cursor VBI for moving cursorI'm not a games programmer. And I'm not a programmer at all!I only wanted for about thousands of years to write mouse program for Atari!Here is routine is known as very fast etc...But I Personally think that The Native Atary - is TEXT interface.Text but NOT Char-keyed!!!(YES! I can imagine as acceptable Char-keyed interface in ESC-sequences combination key command-mode)But really I need TEXT-Cursor Inverse mode for controlling Atari.Here is code for getting pixel controlled cursor movement... * * ATARI STM1 MOUSE Driver * * OS Equates PMBASE EQU $D407 STRIG1 EQU $0285 PCOLR0 EQU $02C0 COLOR3 EQU $02C7 GPRIOR EQU $026F PORTA EQU $D300 SDMCTL EQU $022F COLPM0 EQU $D012 GRACTL EQU $D01D HPOSP0 EQU $D000 HPOSM0 EQU $D004 STRIG0 EQU $0284 NMIEN EQU $D40E VDSLST EQU $0200 SDLSTL EQU $0230 SDLSTH EQU $0231 VCOUNT EQU $D40B DMACTL EQU $D400 * SETVBV EQU $E45C SYSVBV EQU $E45F XITVBV EQU $E462 * POKMSK EQU $10 VTIMR1 EQU $0210 IRQEN EQU $D20E AUDC1 EQU $D201 AUDF1 EQU $D200 STIMER EQU $D209 CRITIC EQU $42 * P0 EQU $0400 PMZONE EQU $8000 * SHLEN EQU SHEND-SHAPE * ORG $8000 * * Init TIMER for reading mouse INIT SEI LDA #MOUSE STA VTIMR1 LDA #MOUSE/256 STA VTIMR1+1 CLI LDA POKMSK ORA #1 STA POKMSK STA IRQEN LDA #0 STA AUDC1 LDA #192 STA AUDF1 STA STIMER * Init PMG for drawing Arrow LDA #$3A STA SDMCTL LDA #$02 STA GRACTL LDA #PMZONE/256 STA PMBASE CLEAR LDY #0 TYA CLR STA PMZONE+P0,Y INY BNE CLR * Init VBI for moving cursor LDA #6 LDX #CURSOR/256 LDY #CURSOR JSR SETVBV RTS * * Read mouse in Timer MOUSE TXA PHA TYA PHA SEI LDA CRITIC BNE SKIPIT LDA #0 STA NMIEN * RDPORT LDA PORTA LSR LSR LSR LSR PHA AND #3 ORA OLDX TAX AND #3 ASL ASL STA OLDX LDY XPOS LDA MOVTAB,X BMI STORX BNE DECRX INCRX INY CPY MAXX BCC STORX DECRX DEY CPY MINX BCC INCRX STORX STY XPOS * PLA LSR LSR AND #3 ORA OLDY TAX AND #3 ASL ASL STA OLDY LDY YPOS LDA MOVTAB,X BMI STORY BNE DECRY INCRY INY JMP CHECKY DECRY DEY CHECKY CPY MINY BCC INCRY CPY MAXY BCS DECRY STORY STY YPOS * LDA #$C0 STA NMIEN SKIPIT CLI PLA TAY PLA TAX PLA RTI * * Move Cursor in VBI CURSOR LDA XPOS STA HPOSP0 * LDY #0 TYA CL0 STA PMZONE+P0,Y INY BNE CL0 * LDY YPOS LDX #SHLEN MOV LDA SHAPE,X STA PMZONE+P0,Y INY DEX BPL MOV * LDA STRIG1 BNE NPRESD LDA #$0E NPRESD STA PCOLR0 * JMP SYSVBV * OLDX DFB 126 OLDY DFB 128 XPOS DFB 126 YPOS DFB 128 MAXX DFB 208 MAXY DFB 224 MINX DFB 48 MINY DFB 32 * * The Indextable 0=no action! MOVTAB DFB 255,1,0,255,0,255,255,1 DFB 1,255,255,0,255,0,1,255 * Cursor shape SHAPE DFB $01,$12,$1C,$3C DFB $3E,$78,$60,$80 SHEND EQU *-1 I ask you about CHAR-cursor CONTROLLED!!!YES! I can CMP old value and new value of XCOORD and then make delay of drawing new position of TEXT cursor,,,I think that there are hundreds desisions how to make it perfectly...Really I want to save intact pixel-controlled cursor data (for further use) and add to program TextCursor-controlled data.Your suggestions,please!!! 2 Quote Link to comment Share on other sites More sharing options...
Rybags Posted June 18, 2016 Share Posted June 18, 2016 You can't easily control the text cursor with a mouse. Simply changing the cursor X/Y doesn't actually get mirrored on the screen until the E: device produces output, ie when a key is pressed. Also having the cursor moved while program output is occurring would just create a huge mess. What you could do though is have a mouse handler that translates mouse movement into keystrokes. Diagonal could be done by queuing 2 keystrokes. You'd have to do the programming so that it doesn't clash with normal keyboard input. In the end though I don't think it'd be very usable. For starters the OS can only process keystrokes at the rate of about 90 or so per second. And controlling a text cursor direct from mouse is kind of clunky. Lastly, the keystroke noise generated would be really annoying but at least on XL/XE you can turn the click off. Quote Link to comment Share on other sites More sharing options...
576XE Posted June 19, 2016 Author Share Posted June 19, 2016 Hi there Rybags! Please look at this code ... LDA MOVTAB,X ;Get table data which are 255 or 0 or 1 BMI STORX ;When 255(or -1) NO ACTION! only store new X data BNE DECRX ;If not 0 then decrement cursor position INCRX INY ;If 0 then increment cursor position ... My question is - "A me interpreted the code correctly?" The documentation says that ZERO means NO ACTION TAKEN! Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted June 19, 2016 Share Posted June 19, 2016 Yes, it's a look up table and the zero entries mean no movement on that axis. Quote Link to comment Share on other sites More sharing options...
576XE Posted June 20, 2016 Author Share Posted June 20, 2016 Hi FJC. May be I slightly skip some education... I think that the code BMI STORX goes to ONLY storing HOR values and then works on Y values. Thus this code skips all treating of input data concerning HORIZONTAL... Brunch with MINUS says that we all - hand's up. I can understand that being NOT a programmer I skip some schoolarships BUT?!! I want to say that Minus skips all treatment. Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted June 20, 2016 Share Posted June 20, 2016 I think that the code BMI STORX goes to ONLY storing HOR values and then works on Y values. Thus this code skips all treating of input data concerning HORIZONTAL... Brunch with MINUS says that we all - hand's up. Hi! Yes you're quite right. This code is some distant cousin of the mouse driver in the GOS, but I had forgotten just how many modifications were made by then. The GOS mouse driver simply adds the values in the LUT to the X and Y coordinates, so in that case, $FF = -1, 1 = +1, and 0 = no change. But the documentation for your routine seems at odds with what's actually happening. The lookup table corresponds to the GOS lookup table, but with the sense of the values altered, so it should at least work. This is the same section of the GOS mouse driver: .proc Mouse lda $d300 cmp old_mouse bne Moved pla rti Moved sta old_mouse and #$f0 lsr ; not really worth using a LUT for this lsr lsr lsr pha stx mtmp1 ; save x and #3 ; ST mouse only ora oldx tax lda mousetab3,x sta oldx lda x_change clc adc mousetab,x sta x_change pla tax lda mousetab2,x ora oldy tax lda mousetab3,x sta oldy lda y_change clc adc mousetab,x sta y_change ldx mtmp1 ; restore x pla rti .endp ; ST mouse index table mousetab ; 0 = no movement, 255 = -1, 1 = +1 .byte 0,255,1,0,1,0,0,255,255,0,0,1,0,1,255,0 mousetab2 .byte 0,0,0,0,1,1,1,1 .byte 2,2,2,2,3,3,3,3 mousetab3 .byte 0,4,8,12 .byte 0,4,8,12 .byte 0,4,8,12 .byte 0,4,8,12 The VBI then adds x_change and y_change to the X and Y coordinates. This saves having to handle 16-bit values in the timer IRQ and software mouse acceleration ensures 8 bits are sufficient for one frame's worth of movement. It's basically the same idea, but using signed direction changes in the lookup table. Quote Link to comment Share on other sites More sharing options...
576XE Posted June 21, 2016 Author Share Posted June 21, 2016 I'm not skilled enough to read clearly this code, but I'll trying! Thank you, FJC. GOD BLESS YOU AND YOUR FAMILY AND CAT! 1 Quote Link to comment Share on other sites More sharing options...
576XE Posted June 24, 2016 Author Share Posted June 24, 2016 Hi, there FJC! I have some questions about your code. 1. Really I think that you've used LUT in this: Moved sta old_mouse and #$f0 lsr ; not really worth using a LUT for this lsr lsr lsr Because Using AND #$F0 for clearing Least Nibble is not needed when we are clearing them with 4*LSR. I really can not to clearly read all logic but I see that - moustab can be renamed by movtab (it gives mouse deltas) or deltatab... - moustab2 can be renamed as losntab - Low Semi-Nibble Tab (or HORTAB) -mousetab 3 can be renamed as hisntab - Hi SemiNibble Tab (or VERTAV) It's some reminense to Joystick values... Here I ask about a logic of creating of ... ... I got it!!! (Such a good boy!!!) Anyway, this program is MUCH MORE clearer and elegance then some others. It's only emulates own Not GrayCode above real GrayCode from mouse!!! and returns one-step deltas. (Really it's not a very distant cousine...) One realized in assembly thinking manner - so unreadable as Basic Other realized in human logic thus someone who reads something about Gray-code logic can see all picture. And moving-deltas is a charm! IMHO you said about "16-bits values" erroneously. (It's a 2-byte word...) Your meaning was - some decimal value from 0 to 15 and thus - Least Nibble. I still can not imagine where must be Delay counter if your code is in timer FE... Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted June 24, 2016 Share Posted June 24, 2016 (edited) Yes, I think the cost of the AND plus the indexed table lookup was equal or greater to three rotates. Other names for the LUTs seem reasonable to me. When talking about 16-bit numbers, I meant the actual coordinate system used by the mouse pointer. Actually only 16-bits on the X-axis, of course (since there are 320 pixels). So the signed 8-bit relative changes accumulated during the timer interrupt are added to X and Y every vertical blank. Diamond GOS, incidentally, used a different scheme. Mouse was sampled using DLIs (spread across the display every 20 lines or so) and the NMI simply queued up raw mouse port readings which were then translated into movement in the VBI (IIRC). Edited June 24, 2016 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
576XE Posted June 24, 2016 Author Share Posted June 24, 2016 My personal Best Wishes! Good old Yo! Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted June 24, 2016 Share Posted June 24, 2016 To you also. Actually make that 9 bits for the X-axis on the GR. 8 screen, of course (and the Antic display portion of the driver capitalises on there only being 1 bit of the MSB used). Quote Link to comment Share on other sites More sharing options...
pirx Posted June 27, 2016 Share Posted June 27, 2016 Diamond GOS, incidentally, used a different scheme. Mouse was sampled using DLIs (spread across the display every 20 lines or so) and the NMI simply queued up raw mouse port readings which were then translated into movement in the VBI (IIRC). I've used the same trick in Operation Blood and other games with mouse support, but only 8 reads on DLI per frame (as many as charset changes). Quote Link to comment Share on other sites More sharing options...
576XE Posted July 3, 2016 Author Share Posted July 3, 2016 You all may laugh or cry ... But I'm in writing a letter which must clearly explain my daughter (She is absolutely not a programmer THUS she understands LISP [really] clearer then me...) How The Mouse works. I've said her that Gray invented the scheme how to expand a rule and how to change it to staying Gray... ... mirroring -> demirroring ... Such a Good Boy!!! Anyway! Are me right that in the case when we are not need position-controlled code like a Gray's we can simulate just binary coded tables? I mean just use Demirroring schema... 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.