6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 5:32 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Need a table help code
PostPosted: Sat Apr 19, 2008 2:17 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
FINALLY back into the pinball program after 2 years. Main jobs got me too busy as heck, got laid off again a month ago, bleah. Had ntoes and new ideas.

One was a text display table which has 128 entries of 8 bytes each. I can create the proper base table address but I cannot pick up the data as needed. Help!



Code:
DisplayShapeTable            = $FC00 ; shapes here
DisplayTextTable            = $F800 ; text data here from $f800-fbff
DisplayTextTablePointerLow         = $20   ; The calculated pointers to the text table
DisplayTextTablePointerHigh         = $21
DisplayTextString            = $22   ; User sets this pointer to the DisplayTexttable

; The above are the memory locations referenced:

MessageCenterMessageInit
; To use, load DisplayTextString with the string number to show.
; Then load MessageCenterstatusFlag with #$01
;
; These point to the base address in the table
; DisplayTextTablePointerLow   = $20
; DisplayTextTablePointerHigh   = $21
; These are loaded from the table:
; MessageCenter1
; MessageCenter2
; MessageCenter3
; MessageCenter4
; MessageCenter5
; MessageCenter6
; MessageCenterTimer
; MessageCenterFlickerRate Make MessageFlickerRate higher than MessageCenterTimer to make solid
; (Message Flicker Rate is 0-127; d7 is the MessageClear At End flag:
; d7 = 0 Dont clear message at end
; d7 = 1 Clear message at end
; All displayed graphics and text are messages


   CLC
   STZ DisplayTextTablePointerHigh      ; Zero the upper base number
   LDA DisplayTextString         ; Get the pointer
   STA DisplayTextTablePointerLow
         
   ASL DisplayTextTablePointerLow      ; Shift everything 3 times over
   ROL DisplayTextTablePointerHigh
   ASL DisplayTextTablePointerLow
   ROL DisplayTextTablePointerHigh
   ASL DisplayTextTablePointerLow
   ROL DisplayTextTablePointerHigh

   CLC
   LDA DisplayTextTablePointerHigh
   ADC #$F8            ; Add in the upper base address
   STA DisplayTextTablePointerHigh      ; And put it back. The table is now prepped.

   LDY DisplayTextTablePointerLow
   LDA ($20), y             ; Get MessageCenter1, $20 is hi, y is low
   STA MessageCenter1
   STA Display1
   INY
   LDA ($20), y             ; Get MessageCenter2
   STA MessageCenter2
   STA Display2
   INY   
   LDA ($20), y             ; Get MessageCenter3
   STA MessageCenter3
   STA Display3
   INY      
   LDA ($20), y             ; Get MessageCenter4
   STA MessageCenter4
   STA Display4
   INY
   LDA ($20), y             ; Get MessageCenter5
   STA MessageCenter5
   STA Display5
   INY   
   LDA ($20), y             ; Get MessageCenter6
   STA MessageCenter6
   STA Display6
   INY
   LDA ($20), y             ; Get MessageCenterTimer
   STA MessageCenterTimer
   INY
   LDA ($20), y             ; Get MessageCenterFlickerRate
   STA MessageCenterFlickerRate


; and the table so far....

   *= $F800
;DisplayTextTable
   .DB $00, $4E, $55, $4C, $4C, $00, $FF, $FF   ; $00 = NULL character
   .DB $00, $00, $00, $00, $00, $00, $80, $00   ; $01 = Blank    
   .DB $00, $54, $45, $53, $54, $00, $80, $FF   ; $02 = TEST
   .DB $50, $41, $53, $53, $45, $53, $80, $FF   ; $03 = PASSES






The memory in play during single stepping shows that the create base add4ress is working, that I get the $F810 created and placed into memory.
(want it to show the "test" string first off)

The problem is the LDA ($20),y command. I need it to reference from the low and high pointers to grab 8 bytes in a row.

Going bananas, as always. Thanks if any ideas can work out here :)

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 19, 2008 3:15 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
I'm sorry, but, can you restate the problem, from the beginning, a bit more clearly? I truely can't understand one word of what you're saying, or what is going on. What is this code actually doing, and what is it's desired output?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 19, 2008 3:30 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
A friend helped me out. What it is doing, it takes a value in DisplayTextString (1-255) and uses it to calculate a table entry point, $F800. Each entry is 8 bytes long and 128 entires for 1K.

the first part of the code calculates the base address of the test string I want to grab. That part works correctly.

The LDA ($20),y is where I had my problem. I preloaded the y register with the low data, not realizing that it added it together. So the $10 loaded in would actually point to $F820, blank space.

So going to give it a shot. Been ages.

This is for the same pinball I've been doing. After it grabs the entries from the table, it uses them to show on a display.

the older version works great in hardware, I wanted to get it working easier with a text string table.

NOW I have to work with some real wierdness, I commended out the JSR to the power up self test. If I put the code back in, the display routine refuses to work and the CPU action is slower or something. If I leafve out the post, the display routine works perfectly. Bleah....

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 19, 2008 10:46 am 
Offline

Joined: Wed Oct 22, 2003 4:07 am
Posts: 51
Location: Norway
It's much simpler if you put each of the 8 values in each own table. You avoid having to multiply with 8 and can access everything directly with Y.

Code:
MessageCenterMessageInit
   LDA (DisplayTextTableEntry1), y       ; Get MessageCenter1
   STA MessageCenter1
   STA Display1

   LDA (DisplayTextTableEntry2), y       ; Get MessageCenter2
   STA MessageCenter2
   STA Display2

   LDA (DisplayTextTableEntry3), y       ; Get MessageCenter3
   STA MessageCenter3
   STA Display3
   
   LDA (DisplayTextTableEntry4), y         ; Get MessageCenter4
   STA MessageCenter4
   STA Display4

   LDA (DisplayTextTableEntry5), y       ; Get MessageCenter5
   STA MessageCenter5
   STA Display5

   LDA (DisplayTextTableEntry6), y         ; Get MessageCenter6
   STA MessageCenter6
   STA Display6

   LDA (DisplayTextTableEntry7), y       ; Get MessageCenterTimer
   STA MessageCenterTimer

   LDA (DisplayTextTableEntry8), y         ; Get MessageCenterFlickerRate
   STA MessageCenterFlickerRate
   RTS



   *= $F800
DisplayTextTableEntry1
   .DB $00, $00, $00, $50

DisplayTextTableEntry2
   .DB $4E, $00, $54, $41

DisplayTextTableEntry3
   .DB $55, $00, $45, $53

DisplayTextTableEntry4
   .DB $4C, $00, $53, $53

DisplayTextTableEntry5
   .DB $4C, $00, $54, $45

DisplayTextTableEntry6
   .DB $00, $00, $00, $53

DisplayTextTableEntry7
   .DB $FF, $80, $80, $80

DisplayTextTableEntry8
   .DB $FF, $00, $FF, $FF


(untested code)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 22, 2008 1:48 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Thowllly wrote:
It's much simpler if you put each of the 8 values in each own table. You avoid having to multiply with 8 and can access everything directly with Y.




Hi Thowilly, that was my previous incarnation of the code revision. It worked fine, no problem. I found that each display column being a seperate table was a tad hard to read for debugging purposes. This form of table makes the entries far easier to understand. The shifting routine for the pointer is used only once during each load, and my program already has a whole slew of time delays to ensure proper operation of some 74LS374 latches.

My mistake was in loading the Y register with the lower value which was ALREADY taken from the offset, so I was doubling the lower pointer which went to blank space at the time.

Here is the working load code. Note that I am not using a loop to load into things because the final 2 values are for seperate display variables.

Also, the reason for multiplying by 8 is because each table entry has 8 entries.




Code:
   STZ DisplayTextTablePointerHigh      ; Zero the upper base number
   LDA DisplayTextString         ; Get the pointer
   STA DisplayTextTablePointerLow
         
   ASL DisplayTextTablePointerLow      ; Shift everything 3 times over
   ROL DisplayTextTablePointerHigh
   ASL DisplayTextTablePointerLow
   ROL DisplayTextTablePointerHigh
   ASL DisplayTextTablePointerLow
   ROL DisplayTextTablePointerHigh


   LDA DisplayTextTablePointerHigh
   ADC #$F8            ; Add in the upper base address
   STA DisplayTextTablePointerHigh      ; And put it back. The pointer is now prepped.

   LDY #$00
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenter1
   STA MessageCenter1
   STA Display1

   INY
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenter2
   STA MessageCenter2
   STA Display2

   INY   
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenter3
   STA MessageCenter3
   STA Display3

   INY      
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenter4
   STA MessageCenter4
   STA Display4

   INY
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenter5
   STA MessageCenter5
   STA Display5

   INY   
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenter6
   STA MessageCenter6
   STA Display6

   INY
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenterTimer
   STA MessageCenterTimer
   STA MessageCenterTimerTemp

   INY
   LDA (DisplayTextTablePointerLow), y    ; Get MessageCenterFlickerRate
   STA MessageCenterFlickerRate
   



and the part of the table.

Code:
   *= $F800
;DisplayTextTable
   .DB $00, $4E, $55, $4C, $4C, $00, $80, $00   ; $00 = NULL character
   .DB $00, $00, $00, $00, $00, $00, $80, $00   ; $01 = Blank    
   .DB $00, $54, $45, $53, $54, $00, $80, $00   ; $02 = TEST
   .DB $50, $41, $53, $53, $45, $53, $80, $03   ; $03 = PASSES


you see how it is MUCH more readable for testing and debugging here!

_________________
"My biggest dream in life? Building black plywood Habitrails"


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 guests


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: