Electronics > Beginners

Assembly code Help! PIC16F57

<< < (19/32) > >>

Electrofinn:

--- Quote ---If they (or he.. I bet anything there was one guy coding and one guy sharing credit :)) were still coding today and wrote a similar program (on a baseline device, for some reason), they probably would have found a much better way to do this.
--- End quote ---
I think you're absolutely right about that, obviously he or "they" managed to achieve it in the end, the PIC16C57 I have is proof of that, but even that, I bet if we were able to see to the contents of that pic there would still be the same theme of unorthodox coding practices going on.

It's shame really, I didn't think for a minute that it would be this hard to sort out.

KL27x:

--- Quote ---It's shame really, I didn't think for a minute that it would be this hard to sort out.
--- End quote ---
You're original question actually wasn't. Adding stuff is much easier than fixing stuff. Debugging code is why I have learned how to patch drywall. :)

So if shoring up those lookup tables doesn't patch things, there isn't much low-hanging fruit left to my knowledge. :(


--- Quote ---"they" managed to achieve it in the end, the PIC16C57 I have is proof of that
--- End quote ---
Much like finishing a PCB and finishing the BOM, sourcing every last part, finishing a quasi professional schematic, and tweaking and verifying all the Gerber settings, and answering stupid questions from the PCB manufacturer/assembler... It's that last few details that suck the worst. If I could do things 95% and stop there, I would have the greatest job in the world.

I've actually lost a final production pcb file before; not yet done that with code, though. Luckily. Code can't be reverse engineered from the chip, unlike a pcb.

Electrofinn:
lol, yeah bit of a bummer.  I do think its kind of curious how the writer couldn't find the final release but could find this one, especially given he seemed quite proud of the success of getting it published after working a year on it and in the video he has the magazine cover on the wall. Me personally would be backing it up everywhere, but then that's me, and maybe my background in computer maintenance tells me never to trust just one back up location. Either way it's frustrating because the original chip is flawless in it's operation, that is kind of why I wanted to at least recreate it because if this chip suddenly goes kaput! it's lost forever.


       

Electrofinn:
Have a very positive update, as of the asm when we added a bitmask and an extra value to the "odds" table I am happy to report the following...

1. The machine seems to consistently run the correct "pattern2" table on a win, which is the problem I didn't realise existed in the source code.

2. The machine seems to consistently run the full and not just half the "pattern2" table on a win, full sound pattern too!

3. The machine did have 2 instances where it didn't run the "pattern" table after 2 seconds of running out of credits (returning to sequence mode), however I realised that if I just waited approx 30-45 seconds the pattern does actually begin to play, which I am actually fine with as it does actually do it and that's the main thing. but perhaps code wise you may know what might be causing that.

4. The machine doesn't always have the option to hold all reels when you insert the first credit upon first switch on, which is desirable as it adds a chance element to the game that the player may or may not be able to bag a jackpot win as the default position of the reels on first switch on is all bars.

I can take no credit for this as all credit goes to KL27x for his excellent work on taking such a borked code and turning it into a working one, as well as your excellent write up, It's been an education. Thank you so much.
 

       

KL27x:
Glad to see it's improving!


--- Quote ---3. The machine did have 2 instances where it didn't run the "pattern" table after 2 seconds of running out of credits (returning to sequence mode), however I realised that if I just waited approx 30-45 seconds the pattern does actually begin to play, which I am actually fine with as it does actually do it and that's the main thing. but perhaps code wise you may know what might be causing that.
--- End quote ---

Well, hmm. if it was NOT doing this before, then maybe we messed something up with the bitmasking. So in hindsight, I figure we can go back to the original version of the code and do a cleaner or more targeted fix.* We're gonna do the mask right in the lookup tables. This way, if his code illogically needs counter_hi (or w/e other registers are being loaded before these lookup tables are called) to be beyond the parameters of the table, this fix will allow for that coder oversight/duality.

*I intended the results of those bitmasks to only affect contents of w, and only where it was loaded just before calling these tables. But I found a spot where I did a mask to the register, itself, at least in my own code I was messing with. In sequence1. I don't know if I gave you that version. But the following fix on the original code will ensure these kinds of mistakes that I might have given you (or that you may have made) will be avoided. (OTOH, maybe a "mistake" was what fixed one or more of the other problems!)

If this works, you can use it like this and simply add just those steps we did in the post were we added "new_byte" in order to extend pattern (which was a "clean" modification), minus any place I put a bitmask in there (if I did so).


--- Code: ---table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
andlw 0x1F ;b'00011111' ;
;32 lines 0-31 ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
addwf pc,f
retlw 40 ;0
retlw 08
retlw 00
retlw 00 ;3

retlw 23 ;4
retlw 77
retlw 5C
retlw 08 ;7

retlw 01
retlw 60
retlw 38
retlw 10 ;11

retlw 00
retlw 01
retlw 62
retlw 3F ;15

retlw 54
retlw 08
retlw 00
retlw 21 ;19

retlw 73
retlw 5C
retlw 08
retlw 01 ;23

retlw 60
retlw 39
retlw 50
retlw 08 ;27

retlw 00
retlw 01 ;29
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;add 2 redundat retlw's to complete this 5 bit table
retlw 01
retlw 01 ;31
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
odds
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
andlw 0x07 ;b'00000111' ;
;8 lines 0-7 ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
addwf pc,f
retlw 28 ;0
retlw 14 ;1
retlw 10 ;2
retlw 0C ;3
retlw 00 ;4
retlw 08 ;5
retlw 08  ;6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;add a redunant relw to complete this 3 bit table
retlw 08  ;7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

pattern
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
andlw 0x1F ;b'00011111' ;
;32 lines 0-31 ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
addwf pc,f
retlw 07f ;0
retlw 0bf
retlw 0df 
retlw 06f ;3

retlw 0b7
retlw 0db
retlw 06d
    retlw 0b6 ;7

retlw 0db
    retlw 0ed
retlw 0f6
retlw 0fb ;11

retlw 0fd
retlw 0fe
retlw 0ff
retlw 0ff ;15

retlw 0ff
retlw 0ff
retlw 0ff
retlw 0ff ;

retlw 0ff
retlw 0ff
retlw 0ff
retlw 0ff ;

retlw 0ff
retlw 0ff
retlw 0ff
retlw 0ff ;

retlw 0ff
retlw 0ff
retlw 0ff
retlw 0ff ;31

pattern2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
andlw 0x0F  ;b'00001111' ;
    ;16 lines 0-15 ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
addwf pc,f

retlw 00 ;0
retlw 81
retlw 0C3
retlw 0E7

retlw 0FF
retlw 0E7
retlw 0C3
retlw 81 ;7

retlw 00
retlw 81
retlw 0C3
retlw 0E7

retlw 0FF
retlw 0E7
retlw 0C3
retlw 81 ;15
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod