6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Jun 06, 2024 5:36 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Jun 05, 2004 5:56 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
I seem to be having a problem getting some single bit values prepared into a single byte. This is for the pinball machine project. The code I am having the problem with is below:

; * * * Matrix Work Time * * *
;
; at each matrix step, do in this order.
; 1. Get the matrix/lights variable created into tempAPort
; 2. put $00 into TempBPort
; 3. kick CA2 down
; 4. kick CA2 back up (this puts the first set of things in there)
; 5. Get 7 segment data and put to TempAPort
; 6. put $40 into TempBPort
; 7. kick /CA2 down
; 8. read TempBPort for the switchs
; 9. push TempBPort into TempSwitchs
; 10. kick CA2 backup
; 11. Process TempSwitches into SwitchRaw variables
; 12. do smallDelay
; Solonoid and sound registers banged only once at the end of 7
; The switch debounce counters go at the end of 7.
; Check out the game mode and then go into the 4 seperate game rule
; areas of game processing :)

; Byte setup
; d7 d6 d5 d4 d3 d2 d1 d0
; Lt3 LT2 LT1 LT0 MX2 MX1 MX0


Matrix2
LDA #$00 ; Clear that work port first...
STA TempAPort
CLC ; Dont want carry in this work
LDA #$02 ; The matrix Number is 02
ADC TempAPort
LDA Light8 ; Upper lane B light
AND #$01
ADC TempAPort ; put it into the port
LDA Light9 ; Bonus 500 light
AND #$01
ASL ; move it over
ADC TempAPort
LDA Light10 ; Double Bonus when lit light
AND #$01
ASL
ASL
ADC TempAPort
LDA Light11 ; L extra ball when lit light
AND #$01
ASL
ASL
ASL
ADC TempAPort
LDA #$40 ; Matrix/light 374 port
STA TempBPort
LDA TempAPort ; Ok, lets push it to the 6522 now.
STA Via_ORA_IRA
LDA TempBPort
STA Via_ORB_IRB

LDA #$0C ; kick down /CA2
STA Via_PCR
NOP ; some time for signal to get into 374
NOP
LDA #$0E ; Kick /CA2 back up again
STA Via_PCR


The way the single byte works, the LT0-LT3 are light returns while the light matrix is strobed by the MX0-MX2 lines. Am thinking I am missing something basic or simply too tired when written, but where am I going wrong here? Help!

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jun 05, 2004 9:26 pm 
Offline
User avatar

Joined: Thu Mar 11, 2004 7:42 am
Posts: 362
1. After evey ADC TempAPort, you're throwing away the result in the accumulator with a subsequent LDA.
2. You probably want to use ORA instead of ADC for setting bits (or EOR for toggling them).
3. You may not need TempAPort at all. You can build the result in the accumulator with the sequence:

Code:
EOR LightN
AND #$FE
EOR LightN
ASL        ; as many times as necessary


assuming LightN will be the same both times (i.e. it's not a port that could change). The first three instructions change only bit 0 of the accumulator. The ASL(s) are used to shift it to its final location (or at least to start to shift it to its final location).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jun 06, 2004 8:07 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Thanks a million. Light(n) is not a port but a set of memory locations corresponding to every sing le light bulb on the playing field, in the wiring array. The setup is that the game logic only needs to turn on d0 of the memory location to turn the liught off or on, and can also check for the state by querying that location.

Theroetically, I could pack the lights into 8 lights per byte, but since I have my hardware set up with 32K or RAM, it is simply not needed.

but again, thanks on the knotty problem! Will let you know how it all works when I get things cranking....

Actually, I DO prefer using the TempAPort for the simple reason that I use that location with different data each time. On the TempB, I have set up d6 and d7 as the AB for a 74139, and the CA2 enables it. The 74139 can enable 3 different 74ls374 latch chips. They latch as follow:

d6 d7
0 0 7 segment drive data
0 1 matrix dfive/light returns
1 0 solonoid drive/sound board

So I use TempAPort as the final data to push to the 374s. More a matter of conention, making the code a tad simple for me to work with. Sure, it can be bummed down a bit more, but the cost would be the ease of reading. I do plan to donate the code for the archives here for a learning experience, and my bit is keeping it readable to a point :)....

In terms of toggling the bit, I had seen the EOR used on the Gottlieb source code, which I decompiled a tiny bit. I found it confusing. I will have it in the inlight light code as a call "JSR ToggleLight" which will have that sort of thing. I would have ANDED with #$01 instead instead of #$FE, as such:

LDA Light1 ; load in the light value
JSR ToggleLight
STA Light1 ; put it back


ToggleLight
EOR #$01
RTS

or if EOR #$01 odesnt work, it would be

EOR #$FF
AND #$01
RTS


This way, I haveit clearly defined instead of being stuck in the middle of my matrix code. I would prefer dealing with the light state in the gaming rules and logic part instead of during my matrix processing time anyways.

Mainloop
do matrix 0-7
switch debounce processing
switchboard to seperate game rules
(for each game rule set)
do logic processing
set output variables and states
JMP Mainloop

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 07, 2004 12:30 am 
Offline

Joined: Thu Jan 16, 2003 12:55 pm
Posts: 64
Location: Indianapolis
I'm not sure I totally understand what's going on here. But I'd do something like this for working with individual bits in a byte:

Code:
lit0_on = %00010000
lit0_off = %11101111

;enable

lda lightstate
ora #lit0_on
sta lightstate

;disable

lda lightstate
and #lit0_off
sta lightstate

;toggle

lda lightstate
eor #lit0_on
sta lightstate


But that's (potentially) packing all 8 lights into one byte and always working with it like that. Probably more appropriate when you have more ROM and less RAM, so I guess that's not what you're needing.

It must be a lot of fun to work on a pinball machine. :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 07, 2004 3:37 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
I'm not very big on constants, thats all. Good idea, though.

this is a specialty pinball project. Anyone in here remember the Fireball home pinball machine back from the 1970's? There is a picture of it on www.Fentonia.com, under projects.

The fatal flaw in the pinball was that it used an F8 cpu by Fairchild, which had the ROM built right into the processor. amd it is completely unavailable right now. So if the CPU blows out, there is literally nobody on earth who can fix it up.

The original program is 2K with 64 bytes of RAM used, so byte packing is quite essential to Jamie's code.

Ergo, my project. Originally, it began life as an SBC, a generic solution for any needs of mine. Plenty of requests for this, so it evolved. It is a 3 board piggyback system which includes an interface board which igoes right into the cpu socket, and a sound board which I am already using in other applications.

I had designed my SBC to give me mucho bang for the buck. There is some addressing precepts from Darryl's which I used and am grateful for. 7 chips total onboard and it sports 32K eprom and 32K RAM memory and a 4 MHz 6502. Eventually, it will go to 65c02, but that is later on.

I have already got the self test working, thanks to the great efforts and a thank you lunch for Garth. (I would have been so much happier if the SBC didnt decide to break a chip while I was brigning it to his place!).

The main matrix is a bit of fun and games, it is the power heart of the program. the other heart would be the individual game rules. As an aside, I decided to make 4 different sets of game rules inside, to give more fun and games variety for the player.

ad if it werent for a parade of friends coming in and out all day long and some roofing I needed to do on my workshop, I wqould have iimplemented the changes today. Sigh.

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jun 26, 2004 5:22 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
UPDATE: Got in the 65C02 and 65C22s, they worked like a champ. Cooler and more voltage resistant, so mew happy.

DclxviL thanks on the ORA statement. I am now getting SOMETHING out of the display as of last night/! Granted, its a complete bit of garbage, but the bit packing was required to get it going, so that part works, at least :)

Memblers: The way it works is 8 matrix lines of 4 light bits each. Those are the ones I assemble into the tempAport gig. It might be hilarious that my vcode is correct and I have bad transistors. Am going to feed in all "8"s and see what comes out. :)

Might have to trade CDs sometime, I have this CD out on the market right now. Its science fiction haunted house music, VERY creepy. Which member are you in your group?

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jun 30, 2004 5:05 pm 
Offline

Joined: Thu Jan 16, 2003 12:55 pm
Posts: 64
Location: Indianapolis
Cool, haunted house music, maybe kinda like some soundscape-type stuff. That sounds really interesting. A CD trade would be good, I'd have to tell you though that our stuff is really weird. And it's mostly from .XM format, some of those files are on the site.

The group I was in is mostly 2 people, I'm Joe on there if you saw the site.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jul 01, 2004 8:46 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
I saw the site, very kewl. And love wierd stuff, I was raised with Morton Subotnick and Frank Zappa music :)

Got some samples of my cd at briefcase.yahoo.com/nightmaretony and also pictures round my farm and of my amusement park rides (yes, I own 2 :)

Turns out I *DID* have a bad driver output! I use a ULN2003 and it had a bad output whihc was great fun. To add to the joy, I went stupid and pointed my shape table pointer to the END of the table, which compounded the joy, as it tried to display part of my interrupt routine! Am working it right, and me happy :). Next project am doing is a message center, aka the print statement, so its all going along nicely...

_________________
"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  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 24 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: