6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 09, 2024 8:46 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Apr 27, 2024 2:25 pm 
Offline

Joined: Sat Apr 27, 2024 1:45 pm
Posts: 2
I've added several commands that send values from EhBasic to my graphics routines, and can thus draw lines and change colors, etc.

However, I'm having trouble figuring out how to send values back the other way. I just get a syntax error.

Can someone give some example code to do such a thing? I'd like to do the same with two or three parameters as well.

I have two commands, VEEK and VOKE. Much like PEEK and POKE, but it does the same with my TMS9918a VRAM. VOKE works just fine.

I'd like to do something like:

Code:
10 A = VEEK(2035)


or

Code:
20 IF PIXEL(230,61) = 1 THEN A$="You hit a wall"


What am I missing?

Here's EhBasic's code:

Code:
BAS_PEEK
      JSR   BAS_F2FX          ; save integer part of FAC1 in temporary integer
      LDX   #$00              ; clear index
      LDA   (Itempl,X)        ; get byte via temporary integer (addr)
      TAY                     ; copy byte to Y
      JMP   BAS_1FD0          ; convert Y to byte in FAC1 AND return



Here's my code: I don't touch X at all.

Code:
basVEEK: ; get a byte from an address in the TMS VRAM
    JSR BAS_F2FX          ; save integer part of FAC1 in temporary integer
    LDA Itempl        ; get byte via temporary integer (addr)
    STA TMS_TMP_ADDRESS
    LDA Itemph
    STA TMS_TMP_ADDRESS +1
    JSR tmsVRAMAddrSetRead
    NOP
    NOP
    NOP
    NOP
    NOP
    LDY TMS_VRAM
    CLI
    JMP BAS_1FD0          ; convert Y to byte in FAC1 AND return



Robb


Last edited by robbbates on Sun Apr 28, 2024 12:34 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 27, 2024 3:07 pm 
Offline

Joined: Sat Apr 27, 2024 1:45 pm
Posts: 2
I've figured it out. After typing the above, I had a revelation.

Rather than slipping in the function into the end right above TK_IRQ, you slip it after TK_DEEK along with other functions so that it can be pre-processed.

Just replicate the arrangement under BAS_FTBM.

Code:
      .word BAS_PEEK-1        ; PEEK()
      .word BAS_DEEK-1        ; DEEK()          new function
      .word basVEEK-1           ; VEEK()
      .word BAS_SADD-1        ; SADD()          new function
      .word BAS_LENS-1        ; LEN()
...

      .byte 5,'P'             ;
      .word LBB_PEEK          ; PEEK
      .byte 5,'D'             ;
      .word LBB_DEEK          ; DEEK
      .byte 5,'V'
      .word LBB_VEEK          ; VEEK
      .byte 5,'S'             ;
      .word LBB_SADD          ; SADD
      .byte 4,'L'             ;
      .word LBB_LEN           ; LEN
      .byte 5,'S'             ;

...

TK_PEEK           = TK_ATN+1        ; PEEK token
TK_DEEK           = TK_PEEK+1       ; DEEK token
TK_VEEK           = TK_DEEK+1       ; VEEK token
TK_SADD           = TK_VEEK+1       ; SADD token
TK_LEN            = TK_SADD+1       ; LEN token
TK_STRS           = TK_LEN+1        ; STR$ token

...

      .word BAS_PPFN-1        ; PEEK(n)         "
      .word BAS_PPFN-1        ; DEEK(n)         "
      .word BAS_PPFN-1        ; VEEK(n)         "
      .word $0000             ; SADD()    none
      .word BAS_PPFS-1        ; LEN($)    process string expression in ()

...

LBB_VAL
      .byte "AL(",TK_VAL      ; VAL(
LBB_VEEK
      .byte "EEK(",TK_VEEK    ; VEEK(
LBB_VMODE
      .byte "MODE",TK_VMODE   ; VMODE



I hope this helps someone else.

Robb


Last edited by robbbates on Sun Apr 28, 2024 12:33 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 27, 2024 10:07 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8178
Location: Midwestern USA
robbbates wrote:
Code:
BAS_PEEK
      JSR   BAS_F2FX          ; save integer part of FAC1 in temporary integer
      LDX   #$00              ; clear index
      LDA   (Itempl,X)        ; get byte via temporary integer (addr)
      TAY                     ; copy byte to Y
      JMP   BAS_1FD0          ; convert Y to byte in FAC1 AND return

By surrounding your code with CODE tags, it becomes easier to read.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sat May 04, 2024 1:00 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Welcome, Robb! Glad you figured it out, and thanks for sharing your technique.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: