Home Page
Posted By: Golden Child Atari Lemans track roms - 06/13/22 10:13 PM
Hi guys,

I got interested in Atari Lemans and was reading the Service Manuals and wanted to see the track patterns in the roms:

After fiddling with lua for a bit I was able to see the track data and the car data in the rom.

I don't know why, but the track doesn't look right unless I remove the 7th horizontal byte.

Code

-- same code but spread out to multiple lines

function prtbyte(b) local i for i=7,0,-1 do if (b & (2^i)) ~= 0 then io.write("*") else io.write (" ") end end end
fnamestable = {"/mnt/z/mame/roms/lemans/005837.n5","/mnt/z/mame/roms/lemans/005838.n4","/mnt/z/mame/roms/lemans/005839.n6"} 
for fni,fn in pairs(fnamestable) do 
f = io.open(fn,"r") a = f:read("*a") 
for z = 0,0x7ff,0x200 do print(fn, z) 
for y=0,31 do for x=0,15 do 
adr = (x | (y<<4)) + z b = a:byte(1+adr) 
if x==0 then io.write("adr:"..string.format("%3x",adr)) end 
if x~=7 then prtbyte(b) end end print() end print(fn,z,"end") end end  
fn = "/mnt/z/mame/roms/lemans/005837.n5"
f = io.open(fn,"r") a = f:read("*a") 
for x = 0,31 do print(fn,x) for y=0,7 do 
adr = (y | (((x & 0x10)>>4) << 3) | ((x & 0xf)<<5)) | (2^9) | (2^10) 
io.write(string.format("%2x",adr).." ") b = a:byte(1+adr) prtbyte(b) 
adr = adr | (2^4) b= a:byte(1+adr) prtbyte(b) 
print("  "..string.format("%2x",adr)) end 
print("------") 
end 


-- same code as a single line

function prtbyte(b) local i for i=7,0,-1 do if (b & (2^i)) ~= 0 then io.write("*") else io.write (" ") end end end
 fnamestable = {"/mnt/z/mame/roms/lemans/005837.n5","/mnt/z/mame/roms/lemans/005838.n4","/mnt/z/mame/roms/lemans/005839.n6"} for fni,fn in pairs(fnamestable) do f = io.open(fn,"r") a = f:read("*a") for z = 0,0x7ff,0x200 do print(fn, z) for y=0,31 do for x=0,15 do adr = (x | (y<<4)) + z b = a:byte(1+adr) if x==0 then io.write("adr:"..string.format("%3x",adr)) end if x~=7 then prtbyte(b) end end print() end print(fn,z,"end") end end  fn = "/mnt/z/mame/roms/lemans/005837.n5" f = io.open(fn,"r") a = f:read("*a")  for x = 0,31 do print(fn,x) for y=0,7 do adr = (y | (((x & 0x10)>>4) << 3) | ((x & 0xf)<<5)) | (2^9) | (2^10) io.write(string.format("%2x",adr).." ") b = a:byte(1+adr) prtbyte(b) adr = adr | (2^4) b= a:byte(1+adr) prtbyte(b) print("  "..string.format("%2x",adr)) end print("------") end 
/mnt/z/mame/roms/lemans/005837.n5	0
adr:  0 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr: 10**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr: 20*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                             
adr: 30                  *                      ****  *                            *                                           
adr: 40                 *               ** ** * ****  *                              *                                         
adr: 50                 *                       ****  *                 ** ** *        *                                       
adr: 60                 *                       ****  * ** ** *                          *                                     
adr: 70                 *          * * * * * * * * * * * * * * * * * * * * * * *           *                                   
adr: 80                 *         *      ***  *           *   *                  *           *                                 
adr: 90                 *         *      ***  *            * *                     *           *                               
adr: a0                 *         *       * * * * * *       *       * * * *          *           *                             
adr: b0                 *         *                   *           *         *          *           *                           
adr: c0                 *         *                    *          *           *         **          *                          
adr: d0                  *         * * * * * * *         *        *            *        *  *        *                          
adr: e0                   *         *    *       *         * * * *      *      *        *   *       *                          
adr: f0                     *         * *          *                    *      *        **  *       *                          
adr:100                       * ** ** * *            *                 *       *        *   *       *                          
adr:110                       * ** ** * *      *       * * * * * * * *        * *        * *        *                          
adr:120                     *         *       *  *                           *   *      * **  *     *                          
adr:130                   *         *        *     *                       *       *    * **  *    *                           
adr:140                  *         *        * * * * * * * * * * * * * * * * * * * * * * * * * * * *                            
adr:150                 *         *       *                       **  * ** ** *                    *                           
adr:160                 *         *      *                        **  * ** ** *                     *                          
adr:170                 *         *      *     ********************************************         *                          
adr:180                 *         *           *    *  *                    *  *            *        *                          
adr:190                 *         *           *    *  *                    *  *            *        *                          
adr:1a0                 *          * * * * * * ********************************************         *                          
adr:1b0                 *               ***** *                                                     *                          
adr:1c0                 *               ***** *                                                     *                          
adr:1d0                 *               ***** *                                                     *                          
adr:1e0                  *              ***** *                                                    *                           
adr:1f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
/mnt/z/mame/roms/lemans/005837.n5	0	end
/mnt/z/mame/roms/lemans/005837.n5	512
adr:200 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:210**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:220*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * *           * * * * *                             
adr:230                  *                              ****  *               *       *            *                           
adr:240                 *                               ****  *                *    *               *                          
adr:250                 *        * * * * * * * * * * * * * * * * * * * *        * *        *       *                           
adr:260                 *         *                 *                   *       *        *       *                             
adr:270                 *         *              *                       *             *       *                               
adr:280                  *       *            * ** ** *    * * * * *       *         *       * * * *                           
adr:290                   *     *          *           *             *       *     *       *        *                          
adr:2a0                  *       *      *           *                 **       * *       *          *                          
adr:2b0                 *         *  *           *         * * *      *  *       *                  *                          
adr:2c0                 *         **          *  ***  * *             *    *      *          *      *                          
adr:2d0                  *       *         *         *  ** ** *      *       *     *       * *      *                          
adr:2e0                   *     *        *        *         * * * * * * * * * *      * * *   *      *                          
adr:2f0                  *       *       *        *       *       *       **  * *     *      *      *                          
adr:300                 *         *       * *       *      *    *         **  *  *     *     *      *                          
adr:310                 *         *       *   *      *      *  *      * * *       *     * * *       *                          
adr:320                  *       *       *     *      *      **      *     *       *    * **  *     *                          
adr:330                   *     *       *     *      **      *      *       *       *   * **  *    *                           
adr:340                  *       *       *  *       * *      *      *        *        * * * * * * *                            
adr:350                 *         *       **      *   *             *         *                    *                           
adr:360                 *         *       *     *      *           *            *       ** ** *     *                          
adr:370                 *         *      *     ********************************************         *                          
adr:380                 *         *           *    *  *                    *  *            *        *                          
adr:390                 *         *           *    *  *                    *  *            *        *                          
adr:3a0                 *          * * * * * * ********************************************         *                          
adr:3b0                 *               ***** *                                                     *                          
adr:3c0                 *               ***** *                                                     *                          
adr:3d0                 *               ***** *                                                     *                          
adr:3e0                  *              ***** *                                                    *                           
adr:3f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
/mnt/z/mame/roms/lemans/005837.n5	512	end
/mnt/z/mame/roms/lemans/005837.n5	1024
/mnt/z/mame/roms/lemans/005837.n5	1024	end
/mnt/z/mame/roms/lemans/005837.n5	1536
/mnt/z/mame/roms/lemans/005837.n5	1536	end
/mnt/z/mame/roms/lemans/005838.n4	0
adr:  0 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr: 10**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr: 20*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
adr: 30                  *              * **  *                                  ***  *            *                           
adr: 40                 *               * **  *                                  ***  *             *                          
adr: 50                 *               * **  *                                  ***  *             *                          
adr: 60                 *               * **  *                                  ***  *             *                          
adr: 70                 *               * **  *                                  ***  *             *                          
adr: 80                 *               * * * * * * * * * * * * * * * * * * * * * * * *             *                          
adr: 90                 *              *                                               *            *                          
adr: a0                 *              *                                               *            *                          
adr: b0                 *              *                                               *            *                          
adr: c0                  *              *                                              *            *                          
adr: d0                   *              *                                             *            *                          
adr: e0                    *              *                                            *            *                          
adr: f0                     *              *********************************************            *                          
adr:100                      *             *       *  *            *  *                *            *                          
adr:110                      *  ****  *    *       *  *            *  *                *            *                          
adr:120                     *   ****  *    *********************************************            *                          
adr:130                    *    ****  *   *                                            *            *                          
adr:140                   *     ****  *  *                                            *   **  *    *                           
adr:150                  *      ****  * *                                            *    **  *   *                            
adr:160                 *              *                                            *     **  *  *                             
adr:170                 *              *                                           *      **  * *                              
adr:180                 *              *                                          *            *                               
adr:190                 *               * * * * * * * * * * * * * * * * * * * * *             *                                
adr:1a0                 *                                       ***** *                      *                                 
adr:1b0                 *                                       ***** *                     *                                  
adr:1c0                 *                                       ***** *                    *                                   
adr:1d0                 *                                       ***** *                   *                                    
adr:1e0                  *                                      ***** *                  *                                     
adr:1f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                       
/mnt/z/mame/roms/lemans/005838.n4	0	end
/mnt/z/mame/roms/lemans/005838.n4	512
adr:200 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:210**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:220*   ****                * * * * * * * *                               * * * * * * *                                     
adr:230                      *          * **  * *                         *      ***  *    *                                   
adr:240                    *            * **  *   *                     *        ***  *      *                                 
adr:250                  *              * **  *     *                 *          ***  *        *                               
adr:260                 *               * **  *       *             *            ***  *          *                             
adr:270                 *               * **  *         *          *             ***  *           *                            
adr:280                 *                *                *       *             * * * *            *                           
adr:290                  *                 *                *    *            *         *           *                          
adr:2a0                    *                 *                *  *           *           *          *                          
adr:2b0                      *                 *               **            *           *          *                          
adr:2c0                        *                 *                           *           *          *                          
adr:2d0                          *                **                         *           *          *                          
adr:2e0                           *               *  *                      *            *          *                          
adr:2f0                          *                *    *                   *             *          *                          
adr:300                        *                 *       *                *              *          *                          
adr:310                      *  ****  *        *           * * * * * *  *                *          *                          
adr:320                    *    ****  *      *                                           *          *                          
adr:330                  *      ****  *    **********************************************           *                          
adr:340                 *       ****  *  *         *  *            *  *                *           *                           
adr:350                 *       ****  **           *  *            *  *               *   **  *   *                            
adr:360                 *              ***********************************************    **  *  *                             
adr:370                 *              *                                            *           *                              
adr:380                 *              *                                           *           *                               
adr:390                 *                * * * * * * * * * * * * * * * * * * * * *            *                                
adr:3a0                 *                                       ***** *                      *                                 
adr:3b0                 *                                       ***** *                     *                                  
adr:3c0                 *                                       ***** *                    *                                   
adr:3d0                 *                                       ***** *                   *                                    
adr:3e0                  *                                      ***** *                  *                                     
adr:3f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                       
/mnt/z/mame/roms/lemans/005838.n4	512	end
/mnt/z/mame/roms/lemans/005838.n4	1024
adr:400 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:410**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:420*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
adr:430                  *                              ** ** *  ***  *                            *                           
adr:440                 *                               ** ** *  ***  *                             *                          
adr:450                 *                               ** ** *  ***  *                             *                          
adr:460                 *                               ** ** *  ***  *                             *                          
adr:470                 *               *********************************************               *                          
adr:480                 *             *    *  *                    *  *       *       *             *                          
adr:490                 *             *    *  *                    *  *               *             *                          
adr:4a0                 *       * **  * *********************************************               *                          
adr:4b0                 *       * **  *                         *                 *                *                           
adr:4c0                  *      * **  *                           *             *                 *                            
adr:4d0                   *     * **  *                             *         *   **  *   **  * *                              
adr:4e0                     *   * **  *                               *      *                *                                
adr:4f0                       * * **  *                                 *   *                *                                 
adr:500                          * * * * * * * * * * * * *                * *                *                                 
adr:510                       *                            *                *                  *                               
adr:520                     *                                *                *                  *                             
adr:530                    *                            ****  **               **                  *                           
adr:540                   *                             ****  *  *             *  *                 *                          
adr:550                  *                              ****  *                *    *               *                          
adr:560                 *                * * * * * * *  ****  *               *      *              *                          
adr:570                 *              *               *                     *        *             *                          
adr:580                 *              *                 *                 *         *              *                          
adr:590                 *                * * * * * * * * * * * * * * * * * * * * * *                *                          
adr:5a0                 *                                       ***** *         ** ** *             *                          
adr:5b0                 *                                       ***** *         ** ** *            *                           
adr:5c0                 *                                       ***** *                           *                            
adr:5d0                 *                                       ***** *                 ** ** * *                              
adr:5e0                  *                                      ***** *                       *                                
adr:5f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                   
/mnt/z/mame/roms/lemans/005838.n4	1024	end
/mnt/z/mame/roms/lemans/005838.n4	1536
adr:600 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:610**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:620*   ****                 * * * * * * * * * * *               * * * * * * * * * * * * *                                  
adr:630                      *                         *         *                             *                               
adr:640                    *                             *     *                                 *                             
adr:650                  *                                 * *                                     *                           
adr:660                 *                                   *                                       *                          
adr:670                 *               * * *               *           * * * * * * * * *           *                          
adr:680                 *             *       *             *            ***  * *        *          *                          
adr:690                 *             *       *             *            ***  *   *      *          *                          
adr:6a0                 *             *       * ****  *     *            ***  *     *    *          *                          
adr:6b0                  *              *   *   ****  *    * *           ***  *       *  *          *                          
adr:6c0                   *     ** ** *   *     ****  *   *    * * * * *               * *          *                          
adr:6d0                    *    ** ** *         ****  * *                *              **          *                          
adr:6e0                      *  ** ** *               *                    *             *          *                          
adr:6f0                        *                    *                       *            *          *                          
adr:700                          *                *                          *           *          *                          
adr:710                        *                    *                        *           *          *                          
adr:720                      *                  * **  ** * * * * * * * * * *             *          *                          
adr:730                    *                    * **  *                                 *           *                          
adr:740                  *                *     * **  *                                *           *                           
adr:750                 *               *   *   * **  *                               *   **  *   *                            
adr:760                 *              *       *                ** ** *              *    **  *  *                             
adr:770                 *              **********************************************     **  * *                              
adr:780                 *              *           *  *            *  *            *           *                               
adr:790                 *               *          *  *            *  *          *            *                                
adr:7a0                 *                 **************************************             *                                 
adr:7b0                 *                               ***** *                             *                                  
adr:7c0                 *                               ***** *                            *                                   
adr:7d0                 *                               ***** *                           *                                    
adr:7e0                  *                              ***** *                          *                                     
adr:7f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                       
/mnt/z/mame/roms/lemans/005838.n4	1536	end
/mnt/z/mame/roms/lemans/005839.n6	0
adr:  0 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr: 10**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr: 20*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
adr: 30                  *      ****  *                                                            *                           
adr: 40                 *       ****  *         ** ** *                                             *                          
adr: 50                 *       ****  *         ** ** *                                             *                          
adr: 60                 *       ****  *                                                             *                          
adr: 70                 *       ****  ***************************************************           *                          
adr: 80                 *            *     *  *           *         *      *  *          *          *                          
adr: 90                 *            *     *  *         *             *    *  *          *          *                          
adr: a0                 *            *******************               ******************           *                          
adr: b0                 *            *                *       **        *              *           *                           
adr: c0                 *            *              *        *  *        *            * * **  *   *                            
adr: d0                 *            * * * * * * *          *    *         * * * * * *  * **  * *                              
adr: e0                 *            *                    * * * * *                           *                                
adr: f0                 *            *                  *          *                        *                                  
adr:100                 *            *                * ** ** *     *                    * * * * *                             
adr:110                 *            *        * * * * *               * * * * * * * * *   **  *    *                           
adr:120                 *            *       *        *               *             *     **  *     *                          
adr:130                 *            *        *       *       *       *           *       **  *     *                          
adr:140                 *            *   ***  **      *       *       *         *         **  *     *                          
adr:150                 *            **  ***  * *     *       *       *       *           *         *                          
adr:160                 *            * *          * *         *         * * *           *  *        *                          
adr:170                 *            *  *                     *                       *    *        *                          
adr:180                 *            *   *                    *                     *     *         *                          
adr:190                 *            *     *                 * *                  *     *           *                          
adr:1a0                 *             * * * * * * * * * * * * * * * * * * * * * * * * *            *                           
adr:1b0                 *                       ***** *                                           *                            
adr:1c0                 *                       ***** *                                         *                              
adr:1d0                 *                       ***** *                                       *                                
adr:1e0                  *                      ***** *                                     *                                  
adr:1f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                     
/mnt/z/mame/roms/lemans/005839.n6	0	end
/mnt/z/mame/roms/lemans/005839.n6	512
adr:200 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:210**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:220*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
adr:230                  *              ****  *        *          *                                *                           
adr:240                 *               ****  *         ** ** *      *                              *                          
adr:250                 *               ****  *          *     *                                    *                          
adr:260                 *               ****  *           *   *                                     *                          
adr:270                 *          * * * * * * * *         * *          * * * * * * * * * *         *                          
adr:280                 *         *      ***  *   *         *         *              *     *        *                          
adr:290                 *         *      ***  *    *        *       *                  *   *        *                          
adr:2a0                 **       **       *          *      *      *                    *  *        *                          
adr:2b0                 *         *        *          *           *                      * *        *                          
adr:2c0                 *         *         *           *         *          *           * *        *                          
adr:2d0                  *         *          *          *         *         *          *  *        *                          
adr:2e0                   *         *           *         *         *        *         *   *        *                          
adr:2f0                     *         *          *         *        *        *         *   *        *                          
adr:300                       * ** ** * *         *         *      *         *          *  *        *                          
adr:310                       * ** ** * *         * *         *  *          * *          **         *                          
adr:320                     *         *           *   *                    *   *        * **  *     *                          
adr:330                   *         *           *       *                *       *      * **  *    *                           
adr:340                  *         *          * * * * * * * * * * * * * * * * * * * * * * * * * * *                            
adr:350                 *         *         *                     **  * ** ** *                    *                           
adr:360                 *         *       *                       **  * ** ** *                     *                          
adr:370                 *         *      *     ********************************************         *                          
adr:380                 *         *           *    *  *                    *  *            *        *                          
adr:390                 *         *           *    *  *                    *  *            *        *                          
adr:3a0                 *          * * * * * * ********************************************         *                          
adr:3b0                 *               ***** *                                                     *                          
adr:3c0                 *               ***** *                                                     *                          
adr:3d0                 *               ***** *                                                     *                          
adr:3e0                  *              ***** *                                                    *                           
adr:3f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
/mnt/z/mame/roms/lemans/005839.n6	512	end
/mnt/z/mame/roms/lemans/005839.n6	1024
adr:400 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:410**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:420*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                 
adr:430                  *              ****  *                                                *                               
adr:440                 *               ****  *                                                 *                              
adr:450                 *               ****  *                                                  *                             
adr:460                 *               ****  *                                                   *                            
adr:470                 *             * * * * * * * * * * * * * * * * * * * * * * * * * *          *                           
adr:480                 *           *                   * **  * ** ** *                   *         *                          
adr:490                 *           *           ** ** * * **  *                            *        *                          
adr:4a0                 *           *        * * * * * * * * * * * * * * * * * * * *        *       *                          
adr:4b0                 *           *       *                    ***  *              *              *                          
adr:4c0                 *           *       *                    ***  *              * *            *                          
adr:4d0                 *           **       *        * * * * * * * * * * *         * * *           *                          
adr:4e0                 *           * *       *      *  *                         *      *          *                          
adr:4f0                 *           *  *       *      **                        *         *        *                           
adr:500                 *           *   *      *      *      * * * * * * * * *    **  *    * * * *                             
adr:510                 *           *  *      *      *      *             *          **            *                           
adr:520                 *           * *      *      *      *           *          *    *            *                          
adr:530                 *           **      *      *      *         *          *         * *        *                          
adr:540                 *           *      *      *        * * * *          *               *       *                          
adr:550                 *           *     *      *                       *                  *       *                          
adr:560                 *           *           * *                   *                     *       *                          
adr:570                 *           *          **********************************************       *                          
adr:580                 *           *         *    *  *                    *  *     *       *       *                          
adr:590                 *           *         *    *  *                    *  *   *        *        *                          
adr:5a0                 *            * * * * * *******************************************         *                           
adr:5b0                 *                       ***** *                                           *                            
adr:5c0                 *                       ***** *                                         *                              
adr:5d0                 *                       ***** *                                       *                                
adr:5e0                  *                      ***** *                                     *                                  
adr:5f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                                     
/mnt/z/mame/roms/lemans/005839.n6	1024	end
/mnt/z/mame/roms/lemans/005839.n6	1536
adr:600 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:610**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:620*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * *           * * * * *                             
adr:630                  *                                      ****  *       *       *            *                           
adr:640                 *                                       ****  *        *    *               *                          
adr:650                 *        * * * * * * * * * * * * * * * * * * * *       *  *        *       *                           
adr:660                 *         *                 *                          **        *       *                             
adr:670                 *         *              *                            *        *       *                               
adr:680                  *       *            * ** ** *   * * * * * * * * * *        *       * * * *                           
adr:690                   *     *          *           *                ** ** *    *       *        *                          
adr:6a0                  *       *      *           *                            *       *          *                          
adr:6b0                 *         *  *           *         * * * * * * * * * * * *       ***  *     *                          
adr:6c0                 *         **          * * **  * *                         *          *      *                          
adr:6d0                  *       *         *         *                             *       * *      *                          
adr:6e0                   *     *        *        *         * * * * * * * * * *      * * *   *      *                          
adr:6f0                  *       *       *        *       *       *       **  * *     *      *      *                          
adr:700                 *         *       * *       *      *    *         **  *  *     *     *      *                          
adr:710                 *         *       *   *      *      *  *      * * *       *     * * *       *                          
adr:720                  *       *       *     *      *      **      *     *       *                *                          
adr:730                   *     *       *     *      **      *      *       *       *   ** ** *    *                           
adr:740                  *       *       *  *       * *      *      *        *        * * * * * * *                            
adr:750                 *         *       **      *   *             *         *                    *                           
adr:760                 *         *       *     *      *           *            *       ** ** *     *                          
adr:770                 *         *      *     ********************************************         *                          
adr:780                 *         *           *    *  *                    *  *            *        *                          
adr:790                 *         *           *    *  *                    *  *            *        *                          
adr:7a0                 *          * * * * * * ********************************************         *                          
adr:7b0                 *               ***** *                                                     *                          
adr:7c0                 *               ***** *                                                     *                          
adr:7d0                 *               ***** *                                                     *                          
adr:7e0                  *              ***** *                                                    *                           
adr:7f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
/mnt/z/mame/roms/lemans/005839.n6	1536	end
/mnt/z/mame/roms/lemans/005837.n5	0
600        **         610
601 ***   ****   ***  611
602 ****************  612
603 ***   ****   ***  613
604       ****        614
605 ***   ****   ***  615
606 ****************  616
607 ***          ***  617
------
/mnt/z/mame/roms/lemans/005837.n5	1
620   **     *        630
621  ***    ***       631
622  **    ****   **  632
623        ***   ***  633
624 ***   ****   **   634
625 **   ****         635
626      ****   ***   636
627             **    637
------
/mnt/z/mame/roms/lemans/005837.n5	2
640    ***    ***     650
641   ***    ***      651
642         ****   *  652
643 ***    ****   **  653
644 **    ****   ***  654
645 *    ****         655
646            ***    656
647           ***     657
------
/mnt/z/mame/roms/lemans/005837.n5	3
660     **     **     670
661   ***    ***      671
662         ***       672
663 ***   ****    **  673
664 **   ****   ****  674
665     ****          675
666            **     676
667          ***      677
------
/mnt/z/mame/roms/lemans/005837.n5	4
680       ***         690
681     **      **    691
682          ****     692
683   **   *****      693
684 **   *****    **  694
685     ****    **    695
686          **       696
687        **         697
------
/mnt/z/mame/roms/lemans/005837.n5	5
6a0         **        6b0
6a1       ***     **  6b1
6a2   **      ****    6b2
6a3 ***    *****      6b3
6a4      *****    **  6b4
6a5     ****    ***   6b5
6a6          **       6b6
6a7        ***        6b7
------
/mnt/z/mame/roms/lemans/005837.n5	6
6c0      ******       6d0
6c1 ****              6d1
6c2 **         *****  6d2
6c3       ******      6d3
6c4     ******        6d4
6c5               **  6d5
6c6             ****  6d6
6c7      ******       6d7
------
/mnt/z/mame/roms/lemans/005837.n5	7
6e0 *****  *****      6f0
6e1 ****   ****       6f1
6e2   **     **       6f2
6e3   **************  6f3
6e4    **********     6f4
6e5     **     **     6f5
6e6     ****   ****   6f6
6e7    *****  ******  6f7

------
...etc from 16 to 31
------




Gran Trak 10 seems to have ta similar track format:


Code


function prtbyte(b) local i for i=7,0,-1 do if (b & (2^i)) ~= 0 then io.write("*") else io.write (" ") end end end
fnamestable = {"/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5"} for fni,fn in pairs(fnamestable) do f = io.open(fn,"r") a = f:read("*a") for z = 0,0x7ff,0x200 do print(fn, z) for y=0,31 do for x=0,15 do adr = (x | (y<<4)) + z b = a:byte(1+adr) if x==0 then io.write("adr:"..string.format("%3x",adr)) end if x~=7 then prtbyte(b) end end print() end print(fn,z,"end") end end  for x = 0,31 do print(fnamestable[1],x) for y=0,7 do adr = (y | (((x & 0x10)>>4) << 3) | ((x & 0xf)<<5)) | (2^9) | (2^10) io.write(string.format("%2x",adr).." ") b = a:byte(1+adr) prtbyte(b) adr = adr | (2^4) b= a:byte(1+adr) prtbyte(b) print("  "..string.format("%2x",adr)) end print("------") end 
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	0
adr:  0 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr: 10**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr: 20*   ****                                          * * * * * *                                                           
adr: 30                  ****************************  *             *  ****************************                           
adr: 40                 *          *  *              *                 *           *  *             *                          
adr: 50                 *          *  *             *                   *          *  *             *                          
adr: 60                  ***************************                     ***************************                           
adr: 70                     *                    * *          *          * *              **  *     *                          
adr: 80                   *                        *          *          *                **  *     *                          
adr: 90                  *                          *         *         *          * * * *          *                          
adr: a0                 *          * * * *           *        *  ***  **         *        *         *                          
adr: b0                 *         *     *           *         *       *         *         *         *                          
adr: c0                 *         *   * ****  *    *         **       **         *        *         *                          
adr: d0                 *         *  *  ****  *  *          * *       *  *          *     *         *                          
adr: e0                 *         * *   ****  **           * *        *    *           *  *         *                          
adr: f0                 *         **          *           *  *          * * * *          **         *                          
adr:100                 *         *          *          *     *                          **         *                          
adr:110                 *         *         *          *        *                       * *         *                          
adr:120                 *         *         *           * * * * * * * * * * * * * * * *   *         *                          
adr:130                 *         *         *                   * **  *                 * *         *                          
adr:140                 *         *          *                  * **  *                   *         *                          
adr:150                 *         **          *                 * **  *                   *         *                          
adr:160           *     *         * *           * * * * * * * * * * * * * * * * *         *         *                          
adr:170                 *         *  *                     ** *                           *         *                          
adr:180                 *         *   *                    ** *                           *         *                          
adr:190                 *         *     *                  ** *                          *          *                          
adr:1a0                 *          * * * * * * * * * * * * * * * * * * * * * * * * * * *            *                          
adr:1b0                 *               ***** *                                                     *                          
adr:1c0                 *               ***** *                                                     *                          
adr:1d0                 *               ***** *                                                     *                          
adr:1e0                  *              ***** *                                                    *                           
adr:1f0                    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	0	end
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	512
adr:200 *  **** *       * *     * *   * * *  *  **   *  ***  * *     ***  *  ***  *  * * *   * * **  * * **   ** **    **      
adr:210**  ******  *** * ***** * **** ** ****  * * **  *  ***  *   * ** **** ** *****   ** **   * ***   * *** * * ****  *  *** 
adr:220*   ****            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *                             
adr:230                  *                 ** * * **  *    ** *                                    *                           
adr:240                 *                  ** * * **  *    ** *                                     *                          
adr:250                 *                  ** * * **  *    ** *                                     *                          
adr:260                 *                  ** * * **  *    ** *                                     *                          
adr:270                 *      ******************* * * * * * * * * * * *******************          *                          
adr:280                 *     *    *  *           *                   *    *  *           *         *                          
adr:290                 *     *    *  *           *                   *    *  *  *        *         *                          
adr:2a0                 *     *********************        * *         ********************         *                          
adr:2b0                 *     *       *            *      **  **                      *   *         *                          
adr:2c0                 *     *      *               *    **  *  *                      * *         *                          
adr:2d0                 *      *    *                  *           * * * * * *           **         *                          
adr:2e0                 *       * *          * *         *                     *          *         *                          
adr:2f0                 **                  *    *         *                    *         *         *                          
adr:300 *               *  *               *       *         * * * * * *        *         *         *                          
adr:310                 *    * * * * * * *           *  ****  **       *        *         *         *                          
adr:320                 *  *       ** *    *           *         *    *        *         **         *                          
adr:330                 **                   *           *         * *        *         * *         *                          
adr:340                 *                     *            *        **       *         *  *         *                          
adr:350                 *          * *         *             *       *      *         *   *         *                          
adr:360           *     *        *     *         *            *       *     *         *   *         *                          
adr:370                 *       *       *          * * * * * *         *     *         *  *         *                          
adr:380                 *       *        *                             *      *         * *         *                          
adr:390                 *        *         *                           *       *         **         *                          
adr:3a0                 *          * * * * * * * * * * * * * * * * * *          *         *         *                          
adr:3b0                 *               ***** *                                 *        ***  *     *                          
adr:3c0                 *               ***** *                                 *        ***  *     *                          
adr:3d0                 *               ***** *                                 *        ***  *     *                          
adr:3e0                  *              ***** *                                * *       ***  *    *                           
adr:3f0                    * * * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * * *                             
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	512	end
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	1024

/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	1024	end
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	1536

/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	1536	end
/mnt/z/mame/roms/gtrak10/gtrak10/074186.j5	0
600        **         610
601 ***   ****   ***  611
602 ****************  612
603 ***   ****   ***  613
604       ****        614
605 ***   ****   ***  615
606 ****************  616
607 ***          ***  617
------
------
etc
------

And the score data:

It has the score data that goes from 0 to 78 by twos.

Code
function prtbyte(b) local i for i=7,0,-1 do if (b & (2^i)) ~= 0 then io.write("*") else io.write (" ") end end end
for i=0,#a-1,4 do io.write(string.format("%2x",(i))..":"..string.format("%2x",a:byte(i+1)).." ") prtbyte(a:byte(i+1)) print() end


400: 0         
404: 7      ***
408: 5      * *
40c: 5      * *
410: 5      * *
414: 5      * *
418: 5      * *
41c: 7      ***
420: 0         
424: 7      ***
428: 5      * *
42c: 5      * *
430: 7      ***
434: 5      * *
438: 5      * *
43c: 7      ***
440: 0         
444:27   *  ***
448:25   *  * *
44c:25   *  * *
450:25   *  * *
454:25   *  * *
458:25   *  * *
45c:27   *  ***
460: 0         
464:27   *  ***
468:25   *  * *
46c:25   *  * *
470:27   *  ***
474:25   *  * *
478:25   *  * *
47c:27   *  ***
480: 0         
484:e7 ***  ***
488:25   *  * *
48c:25   *  * *
490:e5 ***  * *
494:85 *    * *
498:85 *    * *
49c:e7 ***  ***
4a0: 0         
4a4:e7 ***  ***
4a8:25   *  * *
4ac:25   *  * *
4b0:e7 ***  ***
4b4:85 *    * *
4b8:85 *    * *
4bc:e7 ***  ***
4c0: 0         
4c4:e7 ***  ***
4c8:25   *  * *
4cc:25   *  * *
4d0:e5 ***  * *
4d4:25   *  * *
4d8:25   *  * *
4dc:e7 ***  ***
4e0: 0         
4e4:e7 ***  ***
4e8:25   *  * *
4ec:25   *  * *
4f0:e7 ***  ***
4f4:25   *  * *
4f8:25   *  * *
4fc:e7 ***  ***
500: 0         
504:a7 * *  ***
508:a5 * *  * *
50c:a5 * *  * *
510:e5 ***  * *
514:25   *  * *
518:25   *  * *
51c:27   *  ***
520: 0         
524:a7 * *  ***
528:a5 * *  * *
52c:a5 * *  * *
530:e7 ***  ***
534:25   *  * *
538:25   *  * *
53c:27   *  ***
540: 0         
544:e7 ***  ***
548:85 *    * *
54c:85 *    * *
550:e5 ***  * *
554:25   *  * *
558:25   *  * *
55c:e7 ***  ***
560: 0         
564:e7 ***  ***
568:85 *    * *
56c:85 *    * *
570:e7 ***  ***
574:25   *  * *
578:25   *  * *
57c:e7 ***  ***
580: 0         
584:87 *    ***
588:85 *    * *
58c:85 *    * *
590:e5 ***  * *
594:a5 * *  * *
598:a5 * *  * *
59c:e7 ***  ***
5a0: 0         
5a4:87 *    ***
5a8:85 *    * *
5ac:85 *    * *
5b0:e7 ***  ***
5b4:a5 * *  * *
5b8:a5 * *  * *
5bc:e7 ***  ***
5c0: 0         
5c4:e7 ***  ***
5c8:25   *  * *
5cc:25   *  * *
5d0:25   *  * *
5d4:25   *  * *
5d8:25   *  * *
5dc:27   *  ***
5e0: 0         
5e4:e7 ***  ***
5e8:25   *  * *
5ec:25   *  * *
5f0:27   *  ***
5f4:25   *  * *
5f8:25   *  * *
5fc:27   *  ***


> for i=1,#a-1,4 do io.write(string.format("%2x",(i))..":"..string.format("%2x",a:byte(i+1)).." ") prtbyte(a:byte(i+1)) print() end

Displays the digits that end in 2

401: 0         
405: 7      ***
409: 1        *
40d: 1        *
411: 7      ***
415: 4      *  
419: 4      *  
41d: 7      ***
421:70  ***    
425:c7 **   ***
429:70  ***    
42d:c7 **   ***
431:e0 ***     
435:80 *       
439:e0 ***     
43d:86 *    ** 
441: 0         
445:27   *  ***
449:21   *    *
44d:21   *    *
451:27   *  ***
455:24   *  *  
459:24   *  *  
45d:27   *  ***
461:38   ***   
465: f     ****
469:18    **   
46d: 7      ***
471:70  ***    
475: 0         
479: 0         
47d: 0         
481: 0         
485:e7 ***  ***
489:21   *    *
48d:21   *    *
491:e7 ***  ***
495:84 *    *  
499:84 *    *  
49d:e7 ***  ***
etc
Posted By: Golden Child Re: Atari Lemans track roms - 06/14/22 01:11 PM
So how does the track data work exactly?

There's special byte patterns that get interpreted as a finish line, a slick, a checkpoint and a score/time display.

We can see this better if we rewrite the prtbyte function to label the bits on the printout and to show byte boundaries:

Code
function prtbyte(b) local i for i=7,0,-1 do if (b & (2^i)) ~= 0 then io.write(i) else io.write (" ") end end io.write("|") end

fnamestable = {"/mnt/z/mame/roms/lemans/005837.n5","/mnt/z/mame/roms/lemans/005838.n4","/mnt/z/mame/roms/lemans/005839.n6"} for fni,fn in pairs(fnamestable) do f = io.open(fn,"r") a = f:read("*a") for z = 0,0x7ff,0x200 do print(fn, z) for y=0,31 do for x=0,15 do adr = (x | (y<<4)) + z b = a:byte(1+adr) if x==0 then io.write("adr:"..string.format("%3x",adr)) end if x~=7 then prtbyte(b) end end print() end print(fn,z,"end") end end  fn = "/mnt/z/mame/roms/lemans/005837.n5" f = io.open(fn,"r") a = f:read("*a")  for x = 0,31 do print(fn,x) for y=0,7 do adr = (y | (((x & 0x10)>>4) << 3) | ((x & 0xf)<<5)) | (2^9) | (2^10) io.write(string.format("%2x",adr).." ") b = a:byte(1+adr) prtbyte(b) adr = adr | (2^4) b= a:byte(1+adr) prtbyte(b) print("  "..string.format("%2x",adr)) end print("------") end




/mnt/z/mame/roms/lemans/005837.n5	0
adr:  0 6  3210| 6      | 6 4    | 6 4   0| 6 4  1 | 65   1 | 654  1 |7     10|7  4  10|7  4  1 |7 5   1 |7 54  1 |7 54   0|7 54    |76      |
adr: 1076  3210|76  321 |7 54321 |7 5432 0|7 5432  |7 5 32  |7  432  |7   3 10| 6543 10| 65432  | 65 32  | 6 432  | 6 432 0| 6 4321 | 6  321 |
adr: 207   3210|        |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5     |        |        |        |        |        |
adr: 30        |        |  5     |        |        | 6543  0|        |        |        |    3   |        |        |        |        |        |
adr: 40        |        | 6      |        | 65 32 0| 6543  0|        |        |        |      1 |        |        |        |        |        |
adr: 50        |        | 6      |        |        | 6543  0|        |        | 65 32 0|        |7       |        |        |        |        |
adr: 60        |        | 6      |        |        | 6543  0| 65 32 0|        |        |        |  5     |        |        |        |        |
adr: 70        |        | 6      |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7       |    3   |        |        |        |        |
adr: 80        |        | 6      |   4    |  543  0|        |   4   0|        |        |  5     |      1 |        |        |        |        |
adr: 90        |        | 6      |   4    |  543  0|        |    3 1 |        |        |    3   |        |7       |        |        |        |
adr: a0        |        | 6      |   4    |   4 2 0| 6 4 2  |     2  |     2 0| 6 4    |      1 |        |  5     |        |        |        |
adr: b0        |        | 6      |   4    |        |       0|        |   4    |     2  |        |7       |    3   |        |        |        |
adr: c0        |        | 6      |   4    |        |        |7       |   4    |       0|        | 65     |     2  |        |        |        |
adr: d0        |        |  5     |    3 1 |7 5 3 1 |7       |  5     |   4    |        |7       | 6  3   |     2  |        |        |        |
adr: e0        |        |   4    |     2  |  5     |  5     |    3 1 |7 5     | 6      |7       | 6   2  |     2  |        |        |        |
adr: f0        |        |     2  |       0| 6      |    3   |        |        | 6      |7       | 65  2  |     2  |        |        |        |
adr:100        |        |       0| 65 32 0| 6      |      1 |        |        |7       |7       | 6   2  |     2  |        |        |        |
adr:110        |        |       0| 65 32 0| 6      |7       |7 5 3 1 |7 5 3 1 |       0| 6      |  5 3   |     2  |        |        |        |
adr:120        |        |     2  |       0|       0|  5     |        |        |      1 |  5     | 6 43  0|     2  |        |        |        |
adr:130        |        |   4    |     2  |      1 |    3   |        |        |    3   |    3   | 6 43  0|    3   |        |        |        |
adr:140        |        |  5     |    3   |     2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4 2 0| 6 4    |        |        |        |
adr:150        |        | 6      |   4    |   4    |        |        |   43  0| 65 32 0|        |        |    3   |        |        |        |
adr:160        |        | 6      |   4    |  5     |        |        |   43  0| 65 32 0|        |        |     2  |        |        |        |
adr:170        |        | 6      |   4    |  5     |76543210|76543210|76543210|76543210|76543210|7654    |     2  |        |        |        |
adr:180        |        | 6      |   4    |       0|    3  0|        |        |    3  0|        |    3   |     2  |        |        |        |
adr:190        |        | 6      |   4    |       0|    3  0|        |        |    3  0|        |    3   |     2  |        |        |        |
adr:1a0        |        | 6      |    3 1 |7 5 3 1 |76543210|76543210|76543210|76543210|76543210|7654    |     2  |        |        |        |
adr:1b0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:1c0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:1d0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:1e0        |        |  5     |        | 65432 0|        |        |        |        |        |        |    3   |        |        |        |
adr:1f0        |        |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5     |        |        |        |
/mnt/z/mame/roms/lemans/005837.n5	0	end
[Linked Image from i.imgur.com]



So all data coming from the roms is inverted.
And different bit patterns will do different items:
Code
65 32 0 is a slick       pattern 01 (24)  not 2 4 reversed = not 4 2
65432 0 is finish line   pattern 00 (24)  not 2 not 4 reversed = 4 2
6543  0 is checkpoint   65 is checkpoint 1
6 43  0 is checkpoint   6  is checkpoint 2
 543  0 is checkpoint    5 is checkpoint 3
  43  0 is checkpoint      is checkpoint 4

checkpoint is pattern 10 (24) 2 not 4 reversed = 4 not 2 and 65 determine checkpoint number

   3  0 is score   pattern 11 (24) 2 4  reversed is not 4 not 2

=========================

0 3 not 1 is special data  (that is one of the finish,slick,checkpoint or score)

Bits 0 1 and 3 determine special data:

[Linked Image from i.imgur.com]

bits 2 and 4 get put into a 9321 decoder to determine the special item to display

bits 5 and 6 determine the checkpoint number

[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 06/15/22 02:05 AM
One of the things that's been puzzling is that one page of the schematics in the Lemans manual is missing. There's 2 pages of sheets 1 and 2 but half of sheet 3 is missing.

Fortunately, the Gran Trak 10 manual has a very similar schematic that can fill in the missing page.

(The schematic says its size D so half must be missing)

[Linked Image from i.imgur.com]




Doing some research on Gran Trak 10 I came across this great write up on fixing a Gran Trak 10 by Ed Fries. It's a really fun read.

https://edfries.wordpress.com/2017/06/14/fixing-gran-trak-10/


My lua script output looks just like the GT10 rom decoding by Mike Salay and Tim Giddens.


The fixing gran trak 10 page has links to 3 different files that are very interesting (3 files, one for each word in "amazing things attached")

https://edfries.files.wordpress.com/2017/06/gt10_rom_memory_map.pdf
https://edfries.files.wordpress.com/2017/06/hybrid_schematics1.pdf
https://edfries.files.wordpress.com/2017/06/direction_coordinates.pdf
Posted By: Golden Child Re: Atari Lemans track roms - 06/16/22 07:45 AM
There's a couple more interesting pages on Ed Fries' site:

https://edfries.wordpress.com/2017/10/23/finding-the-first-videogame-rom/

https://edfries.wordpress.com/2017/03/22/chasing-the-first-arcade-easter-egg/


According to a forum post in 2013 by Stiletto at https://forums.arcade-museum.com/threads/old-rom-chips-need-replacing.177683/ ,
the rom in the Gran Trak 10 is a Mostek MK28000 PROM:

Quote
In case this comes up AGAIN, here is the preliminary datasheet for the Atari Le Mans PROM.

It's been identified through past Internet research as a Mostek MK28000 PROM (the same as in Tank / Tank II.)
313K mk28000p.pdf - http://www.sendspace.com/file/36nkqm

Also here are the databooks which contain it.
http://bitsavers.trailing-edge.com/pdf/mostek/_dataBooks/1977_Mostek_Memory_Products.pdf - 06-Aug-2013 14:47 17M
http://bitsavers.trailing-edge.com/...stek_Memory_Data_Book_and_Designers_Guide.pdf - 06-Aug-2013 18:07 38M

(these links are dead but it's there at bitsavers under Components)
http://bitsavers.trailing-edge.com/components/mostek/_dataBooks/

=================

Sometimes you can't figure out how things work unless you build a model. I couldn't quite see how the horizontal counter system worked in Lemans.

The manual lays it out, but that seems confusing.

[Linked Image from i.imgur.com]

So let's take the schematic and make a logisim model:

[Linked Image from i.imgur.com]

[Linked Image from i.imgur.com]

and what you see is that 512H isn't actually 512H but represents more of the "right half of the screen" since it gets set after the 0x1c2 clock and the counter gets reset but leaving the 512H bit making 0x200.
(In other words, the counter jumps from 0x1c2 to 0x200).
Once it hits 0x3c2 then it gets reset again back to 0x000, and then does HSYNC for 32 clocks.

This explains why the 7th row byte disappears in the racetrack. 512/64 = 8 for 8 bytes, but 0x1c2 / 64 = 7.03 so it jumps from 0x1c2 to 0x200 which skips that seventh byte.
Posted By: Golden Child Re: Atari Lemans track roms - 06/17/22 08:53 PM
Studying the ROM addressing is kinda overwhelming at first, but they've given a nice table in the manual to help out.

There's 6 groups given:

CAR = AB
SCORE = C
TIME = D
RACETRACK1 = E
RACETRACK2 = F
SPEED CODE = G


(I think B is supposed to be for a dual player version like Gran Trak 20, you see B mentioned on the schematics)
(E and F are pretty much the same thing, just differing by the TSA track select A)



[Linked Image from i.imgur.com]


[Linked Image from i.imgur.com]


[Linked Image from i.imgur.com]


Theres a bunch of 74153 multiplexers to choose the various inputs specific to each group. The lower 3 74153s handle A0 A1 A2 A3 and A5 A6. The upper 74153 does A7 and A8.

The lower group has ABCD coming in on select 1 and CDEF coming in on select 2.

If the bit on a select is 0 then choose the group items that aren't part of it (ie invert the set)
total set = ABCDEFG
so select1 = ABCD inverted select 1 is EFG
and select 2 = CDEF inverted select 2 = ABG


sel2 sel 1
11 = CD (select 1 = 1 ABCD select 2 = 1 CDEF, interesection is CD)
10 = EF (select 1 = 0 EFG select 2 = 1 CDEF, intersection is EF)
01 = AB (select1 = 1 ABCD select 2 = 0 ABG, intersection is AB)
00 = G (select1=0 EFG and select 2 = 0 ABG, intersection is G)

===================

The upper 74153 is a little different

select 1 is depends on 512H and also on LD1B (AB).
This has the effect of displaying the score on the left half of the screen and the time on the right half.
select 2 is not SCOREDISP (since SCOREDISP is basically CD) so select 2 is not CD = select 2 is ABEFG

11 = EFG (not LD1B = not AB = CDEFG, intersecting with ABEFG, result is EFG)
10 = AB (LD1B = AB intersecting with ABEFG, result is AB)
01 = D time (CD choosing either C or D depending on 512H)
00 = C score


The speed code is interesting because the speed data resides in the first 0x21 bytes of the track. byte 0 to 0x1f are speed codes for the 31 different directions and byte 0x20 is the stop code.
When the car has a "stop condition" 1STOP = 1 and address becomes 0x20 because the output strobe to the 74153 are shut off, so A0 to A4 is 0, while A5 is set to 1.

I think that the speed data is accessed during the VSYNC so the address bits A6 to A8 should be zero. There's no separate logic to gate off A6-A8 for speed code G since those bits 64V, 128V and 256V are expected to be zero during the VSYNC.

======================

so I think what happens is that on VSYNC, the horizontal and vertical motion counters get loaded with rom data from the SPEED G address.

on each HSYNC, the graphics for the car get loaded from the CAR A Address.

As the screen scans, the horizontal counters load the track data from the RACETRACK EF address.

Special codes in the racetrack data do things like SLICK (which requires no data) and SCOREDISP (which will read 8 bits to display from the SCORE C or TIME D address at the next fetch opportunity, so it actually displays in the next track byte after the code appears in the track)

The other special codes are CHECKPOINT 1-4 and FINISH LINE.
Posted By: Golden Child Re: Atari Lemans track roms - 06/20/22 12:02 AM
One of the things that was puzzling me was how the reset car position worked, why does it show up in the center of the track about line 0x1B0?

I looked at this and looked at it, and couldn't figure out how it gets put there.

If you look at a track, it shows up at offset 0x1b0 (since this track starts at 0x600, it is on the line 0x7b0) in the middle.
Code
/mnt/z/mame/roms/lemans/005839.n6	1536
adr:600 6  3210| 6      | 6 4    | 6 4   0| 6 4  1 | 65   1 | 654  1 |7     10|7  4  10|7  4  1 |7 5   1 |7 54  1 |7 54   0|7 54    |76      |
adr:61076  3210|76  321 |7 54321 |7 5432 0|7 5432  |7 5 32  |7  432  |7   3 10| 6543 10| 65432  | 65 32  | 6 432  | 6 432 0| 6 4321 | 6  321 |
adr:6207   3210|        |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |        |  5 3 1 |7 5     |        |        |        |
adr:630        |        |  5     |        |        |        |        | 6543  0|       0|       0|        |    3   |        |        |        |
adr:640        |        | 6      |        |        |        |        | 6543  0|        |7    2  |        |     2  |        |        |        |
adr:650        |        | 6      |  5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7       |7  4    |    3   |    3   |        |        |        |
adr:660        |        | 6      |   4    |        |     2  |        |        |        |76      |  5     |  5     |        |        |        |
adr:670        |        | 6      |   4    |        |  5     |        |        |       0|        |7       |7       |        |        |        |
adr:680        |        |  5     |  5     |       0| 65 32 0|   4 2 0| 6 4 2 0| 6 4 2  |      1 |      1 |7 5 3   |        |        |        |
adr:690        |        |   4    | 6      |    3   |        |7       |        | 65 32 0|    3   |    3   |     2  |        |        |        |
adr:6a0        |        |  5     |  5     | 6      |     2  |        |        |        |  5     |  5     |     2  |        |        |        |
adr:6b0        |        | 6      |   4  1 |        |  5     |    3 1 |7 5 3 1 |7 5 3 1 |7 5     |  543  0|     2  |        |        |        |
adr:6c0        |        | 6      |   43   |       0| 6 43  0| 6      |        |        |   4    |      1 |     2  |        |        |        |
adr:6d0        |        |  5     |  5     |    3   |      1 |        |        |        |    3   |    3 1 |     2  |        |        |        |
adr:6e0        |        |   4    | 6      |  5     |   4    |     2 0| 6 4 2 0| 6 4 2 0|      1 |7 5   1 |     2  |        |        |        |
adr:6f0        |        |  5     |  5     |  5     |   4    |   4    |   4    |   43  0| 6     0|      1 |     2  |        |        |        |
adr:700        |        | 6      |   4    |   4 2  |     2  |    3   | 6      |   43  0|  5     |7     1 |     2  |        |        |        |
adr:710        |        | 6      |   4    |   4   0|      1 |     2  |7      0| 6 4    |   4    | 6 4 2  |     2  |        |        |        |
adr:720        |        |  5     |  5     |  5     |7      0|      10|      1 |    3   |    3   |        |     2  |        |        |        |
adr:730        |        |   4    | 6      | 6     0|      10|      1 |     2  |     2  |     2  | 65 32 0|    3   |        |        |        |
adr:740        |        |  5     |  5     |  5  2  |     2 0|      1 |     2  |      1 |       0| 6 4 2 0| 6 4    |        |        |        |
adr:750        |        | 6      |   4    |   43   |   4   0|        |     2  |       0|        |        |    3   |        |        |        |
adr:760        |        | 6      |   4    |   4    | 6      |7       |    3   |        | 6      | 65 32 0|     2  |        |        |        |
adr:770        |        | 6      |   4    |  5     |76543210|76543210|76543210|76543210|76543210|7654    |     2  |        |        |        |
adr:780        |        | 6      |   4    |       0|    3  0|        |        |    3  0|        |    3   |     2  |        |        |        |
adr:790        |        | 6      |   4    |       0|    3  0|        |        |    3  0|        |    3   |     2  |        |        |        |
adr:7a0        |        | 6      |    3 1 |7 5 3 1 |76543210|76543210|76543210|76543210|76543210|7654    |     2  |        |        |        |
adr:7b0        |        | 6      |        | 65432 0|        |        |STARTPOS|        |        |        |     2  |        |        |        |
adr:7c0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:7d0        |        | 6      |        | 65432 0|        |        |        |        |        |        |     2  |        |        |        |
adr:7e0        |        |  5     |        | 65432 0|        |        |        |        |        |        |    3   |        |        |        |
adr:7f0        |        |    3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5 3 1 |7 5     |        |        |        |


Well, the vertical position counter is 12 bits (0-4096) and if we reset it to zero at the start of the frame, where will the car end up?

The screen is 521 lines so let's divide 4096 by 521.

so we divide it and we get 7.86 frames

> (4096 / 521)
7.8618042226488

multiply 7 * 521 = 3647

and subtract 4096 - 3647 = 449 which is 0x1c1 which is really close to 0x1b0. Maybe it's slightly different because of when the vertical blank hits.


===============================




[Linked Image from i.imgur.com]


Also I was trying to figure out how the 9314 worked (used to do checkpoints and scoring) and recreate it in Logisim, but it's got this weird symbol that looks like an AND gate but the inputs come into the side.

What does this mean?

edit: after a bunch of searching around, it's a wired and.

[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 06/20/22 06:43 AM
After building a circuit for the 9314, it makes it easy to see how the checkpoint system works.

Each point has to be hit in sequence and hitting the finish line resets it.

[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 06/21/22 11:37 PM
One of the things that had me puzzled was this circuit for the extended play. If you score a certain amount, you get a free game, but only one free game per credit.

[Linked Image from i.imgur.com][Linked Image from i.imgur.com]

[Linked Image from i.imgur.com]

so hitting free game signal (FGS) will cause both NAND SR latches to flip

but it doesn't look like anything actually changed because NOT EXTENDED PLAY seems to remain 1.

[Linked Image from i.imgur.com]


So I built the circuit in Lushprojects circuitjs and it becomes easy to see, when you hit FGS, it causes NOT EXTENDED PLAY to go momentarily to 0, then that 0 feeds back to the 7410 input, flipping the SR latch making the topmost input to the second stage 7410 a zero which makes NOT EXTENDED PLAY go back to 1.

[Linked Image from i.imgur.com]

If you look at the scope on the bottom, you can see the voltage drop down momentarily (the green line) to make a logic 0 and then go right back up.
It took me awhile to figure out how to add a scope to the bottom pane, add Voltmeter/Scope Probe, then right click on it and View in New Scope.


Circuitjs saves its circuits as text so you can select "Import from Text" and paste this in:

https://lushprojects.com/circuitjs/circuitjs.html

Code
$ 3 0.0000049999999999999996 1.0312258501325766 83 5 50 5e-11
151 464 288 704 288 0 2 0 5
151 464 368 704 368 0 2 5 5
151 720 320 1040 320 0 3 5 5
w 704 288 720 304 0
w 704 368 464 304 0
w 704 288 464 352 0
w 464 384 1040 384 0
L 720 320 464 448 0 1 false 5 0
L 720 336 416 528 0 0 false 5 0
L 464 272 384 208 0 1 false 5 0
O 1040 320 1200 288 0 0
M 1040 320 1184 352 0 2.5
r 1040 320 1040 384 0 100
c 1040 384 1040 432 0 1e-7 4.999999999999998 0.001
g 1040 432 1040 480 0 0
p 1040 384 1200 384 1 0 0
o 15 1 0 4098 5 0.1 0 1

So now after modeling the whole circuit I can see how it works:

[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 06/24/22 08:31 AM
[Linked Image from i.imgur.com]

Experimenting with the existing gran trak 10 driver to see what it does by enabling some of the "hacks".

I hacked on my bitmap printer device to make a little "scope" display to visualize the signal.

Using a NETDEV_ANALOG_CALLBACK_MEMBER I can get the value of an output.


I modeled it after the way it outputs the video to the fixed frequency monitor device.

It complained if I tried to set a duplicate of the VIDEO_OUT so I chose the COMP_SYNC signal.



Code
	NETLIST_CPU(config, "maincpu", GTRAK10_VIDCLOCK).set_source(netlist_gtrak10);

	BITMAP_PRINTER(config, m_bitmap_printer, 902, 521, 72, 72);  // do 72 dpi
	m_bitmap_printer->set_pf_stepper_ratio(1,1);  //
	m_bitmap_printer->set_cr_stepper_ratio(1,1);

	NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0", 0).set_params("VIDEO_OUT", "fixfreq", FUNC(fixedfreq_device::update_composite_monochrome));

	NETLIST_ANALOG_OUTPUT(config, "maincpu:test1", 0).set_params("COMP_SYNC", "bmp", FUNC(bitmap_printer_device::update_test));


Adding the following to bitmap_printer_device.h:

Red = 0V, Green = 2.5V, Blue = 5V

Code
int m_testx = 0;
	int m_testy = 0;
	double m_test_last_time = 0.0;
	double m_test_xposd = 0.0;
	double m_test_horizscale = 1.0 / 14.318e6;  // single pixel
	int m_lastx = 0;
	int m_rowsize = 40;
	int m_rowgap = 40;

NETDEV_ANALOG_CALLBACK_MEMBER(update_test) 
{
	printf("UPDATE TEST: %f  data= %f\n", time.as_double(), data);

	double m_time_elapsed = time.as_double() - m_test_last_time;
	m_test_xposd += m_time_elapsed / m_test_horizscale;
	if (m_test_xposd >= m_paper_width)  
	{
		m_test_xposd = 0; m_lastx = 0;
		m_testy = m_testy + m_rowsize + m_rowgap;
		if (m_testy >= m_paper_height-m_rowsize - m_rowgap) m_testy = 0; 
	}
	m_testx = m_test_xposd;
	for (int x = m_lastx; x<= m_testx; x++)
	for (int y=m_testy; y < m_testy + m_rowsize + m_rowgap; y++) draw_pixel(x,y,0xffffff);
	for (int x = m_lastx; x<= m_testx; x++)
	{
		draw_pixel(x,m_testy  + m_rowsize - data * (m_rowsize / 5.0), 0);
		draw_pixel(x,m_testy  + m_rowsize - 0.0 * (m_rowsize / 5.0), 0xff0000);  // red
		draw_pixel(x,m_testy  + m_rowsize - 2.5 * (m_rowsize / 5.0), 0x00ff00);  // green
		draw_pixel(x,m_testy  + m_rowsize - 5.0 * (m_rowsize / 5.0), 0x0000ff);  // blue
	}
	m_test_last_time = time.as_double();
	m_lastx = m_testx;
}
Posted By: Golden Child Re: Atari Lemans track roms - 06/26/22 08:19 PM
After making some more analog outputs so I could see what's happening with gran trak 10:



Code
NETLIST_ANALOG_OUTPUT(config, "maincpu:data0", 0).set_params("DATA0", "bmp", FUNC(bitmap_printer_device::update_data0));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data1", 0).set_params("DATA1", "bmp", FUNC(bitmap_printer_device::update_data1));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data2", 0).set_params("DATA2", "bmp", FUNC(bitmap_printer_device::update_data2));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data3", 0).set_params("DATA3", "bmp", FUNC(bitmap_printer_device::update_data3));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data4", 0).set_params("DATA4", "bmp", FUNC(bitmap_printer_device::update_data4));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data5", 0).set_params("DATA5", "bmp", FUNC(bitmap_printer_device::update_data5));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data6", 0).set_params("DATA6", "bmp", FUNC(bitmap_printer_device::update_data6));
NETLIST_ANALOG_OUTPUT(config, "maincpu:data7", 0).set_params("DATA7", "bmp", FUNC(bitmap_printer_device::update_data7));

#define DEBUGNLAO(x,y) NETLIST_ANALOG_OUTPUT(config, "maincpu:"#x, 0).set_params(#y, "bmp", FUNC(bitmap_printer_device::update_##x));

DEBUGNLAO(a0,A0)
...
and then a corresponding printing routine:

Code
#define DEBUGITEM(x) NETDEV_ANALOG_CALLBACK_MEMBER(update_##x) {printf("UPDATE " #x ": %f  "#x"= %f\n",time.as_double(),data); }

DEBUGITEM(data0)
DEBUGITEM(data1)
DEBUGITEM(data2)
DEBUGITEM(data3)
DEBUGITEM(data4)
DEBUGITEM(data5)
DEBUGITEM(data6)
DEBUGITEM(data7)
DEBUGITEM(a0)
...

I could see that nld_tms4800 rom wasn't outputting any data,
so after fixing that

Code
			else
			{
//				unsigned d = 0x00;   // doesn't actually output any data setting d to zero
				unsigned d = m_last_data;
				for (std::size_t i=0; i<4; i++)
				{
					if (m_OE1())
						m_D[i].push((d >> i) & 1, delay);
					if (m_OE2())
						m_D[i+4].push((d >> (i+4)) & 1, delay);
				}
			}
		}

[Linked Image from i.imgur.com]

It looks a little bit recognizable. I'm really confused by fixfreq.cpp and how it handles the sync so I see about one frame of screen then nothing.
Posted By: Golden Child Re: Atari Lemans track roms - 06/27/22 05:09 PM
There's some very strange addressing of the rom occurring. It doesn't seem to count in sequence properly.


If I put some printfs in the TMS4800 the addresses don't count up neatly.
I would expect it to be from 0 to F in sequence.

Code
TMS4800 ROM ADDRESS 0 = 4f   6  3210
TMS4800 ROM ADDRESS 1 = 40   6      
TMS4800 ROM ADDRESS 1 = 40   6      
TMS4800 ROM ADDRESS 2 = 50   6 4    
TMS4800 ROM ADDRESS 2 = 50   6 4    
TMS4800 ROM ADDRESS 3 = 51   6 4   0
TMS4800 ROM ADDRESS 3 = 51   6 4   0
TMS4800 ROM ADDRESS 4 = 52   6 4  1 
TMS4800 ROM ADDRESS 4 = 52   6 4  1 
TMS4800 ROM ADDRESS 5 = 62   65   1 
TMS4800 ROM ADDRESS 5 = 62   65   1 
TMS4800 ROM ADDRESS 6 = 72   654  1 
TMS4800 ROM ADDRESS 6 = 72   654  1 
TMS4800 ROM ADDRESS 7 = 73   654  10
TMS4800 ROM ADDRESS 3 = 51   6 4   0
TMS4800 ROM ADDRESS b = a2  7 5   1 
TMS4800 ROM ADDRESS a = 92  7  4  1 
TMS4800 ROM ADDRESS 8 = 83  7     10
TMS4800 ROM ADDRESS 8 = 83  7     10
TMS4800 ROM ADDRESS 9 = 93  7  4  10
TMS4800 ROM ADDRESS 9 = 93  7  4  10
TMS4800 ROM ADDRESS a = 92  7  4  1 
TMS4800 ROM ADDRESS a = 92  7  4  1 
TMS4800 ROM ADDRESS b = a2  7 5   1 
TMS4800 ROM ADDRESS b = a2  7 5   1 
TMS4800 ROM ADDRESS c = b2  7 54  1 
TMS4800 ROM ADDRESS c = b2  7 54  1 
TMS4800 ROM ADDRESS d = b1  7 54   0
TMS4800 ROM ADDRESS d = b1  7 54   0
TMS4800 ROM ADDRESS e = b0  7 54    
TMS4800 ROM ADDRESS e = b0  7 54    
TMS4800 ROM ADDRESS f = c0  76      
TMS4800 ROM ADDRESS b = a2  7 5   1 
TMS4800 ROM ADDRESS 3 = 51   6 4   0
TMS4800 ROM ADDRESS 2 = 50   6 4    
TMS4800 ROM ADDRESS 0 = 4f   6  3210



If I look at the output from the 9316 at L2, it doesn't seem to obey strict ordering: however, the sequence is always the same:

If you skip spurious values you can see that it does count from 0 to F and back to 0 again.

It makes sense if you look at the output at a specific time, but I think that the TMS4800 will just look as soon as AR is active
with no delay.


Code

Adding some code to track the value of L2 (9316):

NETDEV_ANALOG_CALLBACK_MEMBER(update_id_1h) {  m_id_1h = (data > 2.5) ? 1 : 0; m_l29316_out = (m_id_8h << 3) | (m_id_4h << 2) | (m_id_2h<<1) | (m_id_1h); printf("UPDATE_id_1h TIME: %f  id_1h= %f  l29316_out=%x\n",time.as_double(),data,m_l29316_out); } 
NETDEV_ANALOG_CALLBACK_MEMBER(update_id_2h) {  m_id_2h = (data > 2.5) ? 1 : 0; m_l29316_out = (m_id_8h << 3) | (m_id_4h << 2) | (m_id_2h<<1) | (m_id_1h); printf("UPDATE_id_2h TIME: %f  id_2h= %f  l29316_out=%x\n",time.as_double(),data,m_l29316_out); } 
NETDEV_ANALOG_CALLBACK_MEMBER(update_id_4h) {  m_id_4h = (data > 2.5) ? 1 : 0; m_l29316_out = (m_id_8h << 3) | (m_id_4h << 2) | (m_id_2h<<1) | (m_id_1h); printf("UPDATE_id_4h TIME: %f  id_4h= %f  l29316_out=%x\n",time.as_double(),data,m_l29316_out); } 
NETDEV_ANALOG_CALLBACK_MEMBER(update_id_8h) {  m_id_8h = (data > 2.5) ? 1 : 0; m_l29316_out = (m_id_8h << 3) | (m_id_4h << 2) | (m_id_2h<<1) | (m_id_1h); printf("UPDATE_id_8h TIME: %f  id_8h= %f  l29316_out=%x\n",time.as_double(),data,m_l29316_out); } 



UPDATE_id_1h TIME: 0.000002  id_1h= 0.100000  l29316_out=0
UPDATE_id_1h TIME: 0.000002  id_1h= 3.999999  l29316_out=1
UPDATE_id_2h TIME: 0.000002  id_2h= 3.999999  l29316_out=3
UPDATE_id_1h TIME: 0.000002  id_1h= 0.100000  l29316_out=2
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=3
UPDATE_id_4h TIME: 0.000003  id_4h= 3.999999  l29316_out=7
UPDATE_id_2h TIME: 0.000003  id_2h= 0.100000  l29316_out=5
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=4
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=5
UPDATE_id_2h TIME: 0.000003  id_2h= 3.999999  l29316_out=7
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=6
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=7
UPDATE_id_8h TIME: 0.000003  id_8h= 3.999999  l29316_out=f
UPDATE_id_4h TIME: 0.000003  id_4h= 0.100000  l29316_out=b
UPDATE_id_2h TIME: 0.000003  id_2h= 0.100000  l29316_out=9
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=8
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=9
UPDATE_id_2h TIME: 0.000003  id_2h= 3.999999  l29316_out=b
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=a
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=b
UPDATE_id_4h TIME: 0.000003  id_4h= 3.999999  l29316_out=f
UPDATE_id_2h TIME: 0.000003  id_2h= 0.100000  l29316_out=d
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=c
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=d
UPDATE_id_2h TIME: 0.000003  id_2h= 3.999999  l29316_out=f
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=e
UPDATE_id_1h TIME: 0.000003  id_1h= 3.999999  l29316_out=f
UPDATE_id_8h TIME: 0.000003  id_8h= 0.100000  l29316_out=7
UPDATE_id_4h TIME: 0.000003  id_4h= 0.100000  l29316_out=3
UPDATE_id_2h TIME: 0.000003  id_2h= 0.100000  l29316_out=1
UPDATE_id_1h TIME: 0.000003  id_1h= 0.100000  l29316_out=0



Other weird things is that the 7493 at F2 seems to pick up spurious values, it should start at zero (which is does) but then immediately jumps to a value of 3?
It's supposed to be clocked by HBLANK, but that seems to fire very early when it should not.

Code
cnt = 0 time = 0.000000  time = 0.000000 data= 0.470887 
UPDATE_id_1v TIME: 0.000000  id_1v= 3.999999  f293_out=1
UPDATE_id_2v TIME: 0.000000  id_2v= 3.999999  f293_out=3   // why is this getting a value of 3?
UPDATE id_16v: 0.000000  id_16v= 3.999999  // the other 93 at H2 is doing the exact same thing 
UPDATE id_32v: 0.000000  id_32v= 3.999999  // the other 93 at H2 is doing the exact same thing getting a value of 3?
TMS4800 ROM ADDRESS 0 = 4f   6  3210
UPDATE abg: 0.000000  abg= 3.999999
UPDATE TEST2: 0.000000  data= 3.999999
UPDATE data7: 0.000000  data7= 3.999999
UPDATE data6: 0.000000  data6= 3.999999
UPDATE data5: 0.000000  data5= 3.999999
UPDATE data4: 0.000000  data4= 3.999999
UPDATE data3: 0.000000  data3= 3.999999
UPDATE data2: 0.000000  data2= 3.999999
UPDATE data1: 0.000000  data1= 3.999999
UPDATE data0: 0.000000  data0= 3.999999
UPDATE a4: 0.000000  a4= 3.999999
UPDATE a9: 0.000000  a9= 3.999999
UPDATE a10: 0.000000  a10= 3.999999
UPDATE abcd: 0.000000  abcd= 3.999999
UPDATE ld1b: 0.000000  ld1b= 3.999999
UPDATE vsync: 0.000000  vsync= 3.999999
UPDATE hblank: 0.000000  hblank= 3.999999   // hblank on?
TMS4800 ROM ADDRESS 400 = 0          
TMS4800 ROM ADDRESS 600 = 1         0
TMS4800 ROM ADDRESS 610 = 80  7       
UPDATE vld1: 0.000000  vld1= 3.999999
UPDATE hblank: 0.000000  hblank= 0.100000 // now hblank off?
UPDATE vsync: 0.000000  vsync= 0.100000
UPDATE a4: 0.000000  a4= 0.100000
TMS4800 ROM ADDRESS 600 = 1         0
UPDATE abg: 0.000000  abg= 0.100000
UPDATE_id_1v TIME: 0.000000  id_1v= 0.100000  f293_out=2
UPDATE TEST: 0.000000  data= 0.103274
cnt = 1 time = 0.000000  time = 0.000000 data= 1.183559 
UPDATE hblank: 0.000000  hblank= 3.999999  // now hblank on?
UPDATE a4: 0.000000  a4= 3.999999
UPDATE TEST: 0.000000  data= 3.435158

Looking at JD's Tank driver, it uses the PROM_MK28000 instead of the TMS4800. Trying that since it may have different timing and I get this:

[Linked Image from i.imgur.com]
Posted By: Just Desserts Re: Atari Lemans track roms - 06/27/22 05:14 PM
As much as I'd love to, I can't really help you here, as it was long enough ago that I have no idea why what I implemented for Tank seems to work better.
Posted By: Golden Child Re: Atari Lemans track roms - 06/27/22 08:16 PM
It's all good, JD. I'm just happy to have something that looks sane 8-)




I think I may have an answer for why the 7493 ends up with a value of 0x3, when it first updates A and B, the current code does an increment without even looking at the state of the clkA or clkB input, just increments both m_a and m_bcd "blindly".

Code
		NETLIB_HANDLERI(updA)
		{
			m_a ^= 1;
			m_QA.push(m_a, out_delay[0]);
		}

		NETLIB_HANDLERI(updB)
		{
			const auto cnt(++m_bcd &= 0x07);
			m_QBCD.push(cnt, out_delay);
		}

edit: Hmmm, changing this code made everything not work at all...
Posted By: Golden Child Re: Atari Lemans track roms - 06/28/22 03:15 AM
After going back to the master version of fixfreq the screen seems to be syncing now.

The car is displaying but for some reason, it is jumping around horizontally and it seems to be skewed. However, it seems to remain on the same vertical position, which is good.


[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 06/28/22 04:18 PM
I tried everything I could think of to make the horizontal counters work for the car display, and it finally occurred to me that for some reason the horizontal count is off by a couple of numbers.

So hard wiring the horizontal counter load to be a 6 instead of an 8 so that it will count two extra before hitting full, I can get the car to display in one place. The car doesn't move when the amount the counter has to count up matches the horizontal size of the screen.

However, it seems to display outside the area of the track. I stuck in a counter and hooked up the directions to the counter outputs to make it spin.

It runs pretty slow, but I'm generating tons of printfs.

edit: turned off all printfs and turned off the debugger and it runs pretty fast, though there's a lot of up and down screen movement.

Posted By: Golden Child Re: Atari Lemans track roms - 06/28/22 11:21 PM
Ok, I'm able to move the car a little. I say a little because it's hard to move it since you're clocking a flip flop. It expects to get pulses. But it will move 8-)

Since the horizontal counter seemed to be two off, I changed the main horizontal counter to use the 1H instead of 2H when it computes the end of the line and it seems to work ok. (The first time I tried it it didn't work, then I remembered that I should change the horizontal counter load back to 8 instead of 6 to match).




I hacked a 74193 counter to drive the 1D1 .. 1D4 and 1R0..1R3 outputs and I can turn the car.

Code

	TTL_74193(TEST_ROT, P,  P, P,  P,      GROUND, P, P1_LEFT_RIGHT.2, P1_LEFT_LEFT.2)

	SWITCH(P1_LEFT_LEFT)
	SWITCH(P1_LEFT_RIGHT)

	NET_C(P1_LEFT_LEFT_GND.1, GND)
	NET_C(P1_LEFT_RIGHT_GND.1, GND)

	NET_C(P1_LEFT_LEFT.1, P1_LEFT_LEFT_GND.2)
	NET_C(P1_LEFT_RIGHT.1, P1_LEFT_RIGHT_GND.2)
	
	NET_C(P1_LEFT_LEFT.2, P1_LEFT_LEFT_PULLUP.2)
	NET_C(P1_LEFT_RIGHT.2, P1_LEFT_RIGHT_PULLUP.2)

	RES(P1_LEFT_LEFT_PULLUP, RES_R(1000))
	RES(P1_LEFT_RIGHT_PULLUP, RES_R(1000))

	RES(P1_LEFT_LEFT_GND, RES_R(100))
	RES(P1_LEFT_RIGHT_GND, RES_R(100))

	NET_C(P1_LEFT_LEFT_PULLUP.1, VCC)
	NET_C(P1_LEFT_RIGHT_PULLUP.1, VCC)

	ALIAS(1R0, TEST_ROT.QA)
	ALIAS(1R1, TEST_ROT.QB)
	ALIAS(1R2, TEST_ROT.QC)
	ALIAS(1R3, TEST_ROT.QD)


	ALIAS(1D1, TEST_ROT.QA)
	ALIAS(1D2, TEST_ROT.QB)
	ALIAS(1D3, TEST_ROT.QC)
	ALIAS(1D4, TEST_ROT.QD)

	ALIAS(SPEED_PULSE, P1_LEFT_UP.2)

	NET_C(P1_LEFT_UP.1, SWITCH_R.2)
	NET_C(SWITCH_R.1, VCC)
	
	RES(SWITCH_R, RES_R(100))
	SWITCH(P1_LEFT_UP)

	RES(SWITCH_R_GND, RES_R(1000))
	NET_C(SWITCH_R_GND.1, GND)
	NET_C(P1_LEFT_UP.2, SWITCH_R_GND.2)





Since it's so hard to keep pressing keys, I clocked it with 512V to create pulses

Code
	TTL_74193(TEST_ROT, P,  P, P,  P,      GROUND, P, RIGHT_PULSES.Q, LEFT_PULSES.Q)

	TTL_7400_NAND(LEFT_PULSES, P1_LEFT_LEFT_HIGH.Q, 512V)
	TTL_7400_NAND(RIGHT_PULSES, P1_LEFT_RIGHT_HIGH.Q, 512V)

	TTL_7404_INVERT(P1_LEFT_LEFT_HIGH, P1_LEFT_LEFT.2)
	TTL_7404_INVERT(P1_LEFT_RIGHT_HIGH, P1_LEFT_RIGHT.2)


	ALIAS(SPEED_PULSE, SPEED_PULSES.Q) 

	TTL_7408_AND(SPEED_PULSES, P1_LEFT_UP.2, 512V)

Posted By: Golden Child Re: Atari Lemans track roms - 06/29/22 12:49 PM
There's some real strangeness with the timing and Netlist.

I thought I'd clean up my code and all of a sudden the horizontal counter wasn't working:


Why would swapping

Code
	TTL_7408_AND(HACK, 1H, P)  // see if changing it to 1H fixes the car
	TTL_7408_AND(E2_A, HACK.Q, 64H)  // see if changing it to 1H fixes the car
with
Code
	TTL_7408_AND(E2_A, 1H, 64H)

make it so the horizontal counter would have different behavior?



Code
#ifdef HORIZ_COUNTER_ADJ
#pragma message "USING 1H CLOCK " HORIZ_COUNTER_ADJ
//	TTL_7408_AND(E2_A, 1H, 64H)
	TTL_7408_AND(HACK, 1H, P)  // see if changing it to 1H fixes the car
	TTL_7408_AND(E2_A, HACK.Q, 64H)  // see if changing it to 1H fixes the car
#else
	TTL_7408_AND(E2_A, 2H, 64H)
#endif	
	ALIAS(2H_AND_64H, E2_A.Q)
	TTL_7410_NAND(J1_C, 2H_AND_64H, 128H, 256H) // 450th horizontal pixel (active low)
	// 256 + 128 = 384 + 64 = 448 + 2 = 450


edit: I tried such things as using a 4 input NAND and an 8 input NAND but neither 1H or 2H work properly. I must've found some combination of timing that works.

// TTL_7420_NAND(J1_C, 1H, 64H, 128H, 256H) // neither 1H or 2H work
// TTL_7430_NAND(J1_C, 1H, 64H, 128H, 256H, P, P, P, P) // neither 1H or 2H work


Guess I'm going to keep the ugliness if it works...

I managed to get the start button to work and it sets the counter to 78 but the score instantly jumps to 8 and the checkpoints aren't working yet, or the countdown.
(edit: looking at the nld_dm9314.cpp it seems that RS mode is not yet implemented for the 9314. That would keep the checkpoints from working 8-)


Another strange thing I'm noticing is that the UI doesn't seem to respond properly.

With a slow driver like netlist, you can bring up the UI menus, but then hitting Enter (to enter Input Settings for example) won't do anything and the UI kinda freezes to keyboard input, but the mouse pointer menu activity is still active.

It's kind of intermittent thing, sometimes it works other times it doesn't.
Posted By: Golden Child Re: Atari Lemans track roms - 06/29/22 03:16 PM
Ok, modifying nld_dm9314.cpp to do some RS action:
Code
		NETLIB_HANDLERI(inputs)
		{
			netlist_time delay = NLTIME_FROM_NS(24); //FIXME!
			if (!m_MRQ())
			{
				/* Reset! */
				for (std::size_t i=0; i<4; i++)
					m_Q[i].push(0, delay);
			} else {
				for (std::size_t i=0; i<4; i++)
				{
					if (m_SQ[i]())
					{
						/* R-S Mode */
						// FIXME: R-S mode is not yet implemented!
						
						// RS mode is just an "extension of regular D mode"

						// way RS mode works is that D and S bar should be high (keeps old value)
						// S bar going low sets output high
						// Data going low and S bar high sets output low
						// S bar going low AND D going low sets output low (D takes precedence)

						if (!m_EQ())
						if (!m_D[i]())  // if D low and SQ high we clear the bit
						{
							m_last_Q &= ~(1 << i);
							m_Q[i].push((m_last_Q & (1<<i))>>i, delay);
						}
					}
					else  // SQ is Low
					{
						/* D Mode */
						if (!m_EQ())
						{
							m_Q[i].push(m_D[i](), delay);
							m_last_Q &= ~(1 << i);
							m_last_Q |= (m_D[i]() << i);
						}
					}
				}
			}
		}

And also realizing that I swapped the D and S parameters when I use the 9314, (really easy to do... 8-)

now I can do a full lap with the checkpoint scoring working!

Yes!

Posted By: Golden Child Re: Atari Lemans track roms - 06/30/22 06:16 PM
I made a PR for my gtrak10 stuff if you'd like to check it out.

https://github.com/mamedev/mame/pull/10013
Posted By: Just Desserts Re: Atari Lemans track roms - 06/30/22 06:19 PM
Looks like you're pretty much YOLO-ing your way into a discrete driver. I like it. Bit tired to be doing any code review today, but if there's anything that Vas hasn't covered about 12-16 hours from now, I'll have a look.
Posted By: Golden Child Re: Atari Lemans track roms - 06/30/22 10:26 PM
I think this driver needs more YOLO! 8-)

Since I'm on a roll, I added the 555 1second timer and it seems to work!

The driver is only running at 10% speed (on my system) so I made the resistance much lower (supposed to be 220K, set it to 20K otherwise I'd never see the end of the countdown).

Once it counts down, the car won't move forward (you can still turn it though).
Posted By: Golden Child Re: Atari Lemans track roms - 07/02/22 11:58 AM
So I looked at the schematic over and over again, trying different things and I've come to the conclusion that the RESET1 D-Latch must depend on the horizontal position somehow, either through HBLANK or 512H.

RESET1 pulse ends when it clocks in a P on the data line. If this happens when 512H goes high, the car will appear in the middle of the screen.


Code
	TTL_7408_AND(Reset1Clock, VLd1_Q, 512H)  // clock the reset1 flipflop depending on 512H
	
	TTL_7474(A4_A, Reset1Clock.Q, P, A6_B.Q, P)
//	TTL_7474(A4_A, VLd1_Q, P, A6_B.Q, P)  // according to schematic
	ALIAS(RESET1_Q, A4_A.Q)
	ALIAS(RESET1,   A4_A.QQ)

	TTL_7400_NAND(A2_B, CAR1VIDEO, COMP_SYNC_Q)
	TTL_7408_AND(A6_B, START_Q, A2_B.Q)


If you think about it awhile (it just came to me), no additional gating necessary.

You can set the flipflop with PRESET_Q so just connecting 512H_Q up will set it and shut off the RESET1.


Code
	TTL_7474(A4_A, VLd1_Q, P, A6_B.Q, 512H_Q)




It's actually kind of interesting to study these early Atari arcade games like Lemans/Gran Trak 10 and Tank because you see the similarities between them and what came later in the 2600. The horizontal and vertical position and motion based on counters, here discrete logic does the counting for vertical and horizontal, whereas the 2600 had the cpu do the vertical counting, and the horizontal counting was done with a polynomial counter with an cpu supplied HMOVE offset.
Posted By: =CO=Windler Re: Atari Lemans track roms - 07/03/22 02:53 AM
Another exciting patent about composing complex graphics without framebuffer is US4383827 and DE3243574A1 about Nürburgring 3, the mythical arcade driving simulator by Reiner Foerst.

http://weltenschule.de/vgames/Nuerburg/Nuerburgring.html

If you are emulating such things, a specimen has apparently survived in the Computer Games Museum of Berlin.

[Linked Image from upload.wikimedia.org]

I am writing on a more detailed summary about the different Foerst hardware platforms. Nürburgring 1 & 2 were the predecessor of Atari "Night Driver" but had mostly analogue computers for car simulation, graphics and sound. Nürburgring 3 had more realistic colour graphics controlled by a Z80 MK3880 CPU but still used much analogue hardware for the simulator.

Foerst GmbH, Historie

According to patent DE3243574A1 the colour graphics works without framebuffer using gate logics with counters to draw the road etc., likely controlled by an eprom. Although this machine yet had no opponent cars, the graphics style of drawing a 3D road with center line and horizontally scrolling 2D backdrop (sky and mountains) had set the standard for games like Sega's "Turbo" (1981, which completely lacked car physics and switched curves as static still pictures) and the famous "Pole Position" (1982 by Namco, having car physics and proper curve motion).

Versions N4/N5 (1982,1983) were fully digital with improved arcade graphics featuring opposing traffic and better character generator. N6 (1986?) was likely for professional simulators only and had very awesome hardware based weather effects (apparently alpha channel) and hardware based area fill and circle segment drawing for a kind of zooming run-length encoded sprite graphics. N7 (1985, used in a serious forklift simulator) employed a custom built highend parallel computer with 3D polygon rendering hardware.

It is unknown how many Nürburgring arcade machines still exist. Apparently a "Nürburgring Power-Slide" (N3 P) stands in the Computerspielemuseum Berlin (computer games museum of Berlin, Germany). On flickr a person "videogamescgi1" uploaded detail photos of a "Nürburgring/1" (N1) including screenshot and PCB rack, those look fresh and suggest that it survived in collector's hands. With the early professional simulators it is hard to guess if some still rot in the cellars of some driving school because nobody seems to care. It would be exciting to emulate at least the graphics engine of the early models - and be it only for art purpose because they were way beyond its time.

Video Game Museum in Berlin (photo of Nürburgring 3 Power-Slide)

https://dewiki.de/Media/Datei:Video_Game_Museum_in_Berlin_(45946031421).jpg

The history of racing games
https://historyofracinggames.wordpress.com/installment-three/

Flickr videogamescgi1 (Nürburgring 1 photos)
https://www.flickr.com/photos/171062989@N03/with/49037010376/
Posted By: Golden Child Re: Atari Lemans track roms - 07/03/22 03:11 PM
Interesting stuff, CO, I was watching the moving pictures until I realized that you can auto translate the German captions into English.

Too bad they had that "youth protection law".


==================

Back to the GT10:

I tried to put a POT (potentiometer) into the netlist, where there's supposed to be a pot to adjust the game timer.


There's a bunch of questions about pots that I don't quite understand:

I tried to use POT but that used three terminals, the POT2 only has two terminals.

You can specify a resistance:


POT2(R72, RES_K(10)) // should be a potentiometer 1M // lemans calls it R40 // Less resistance, faster count
POT2(R71, RES_K(60)) // lemans calls it R39 // should be 220K , we'll set to less because we want to see it count

and you can specify a dial setting:

PARAM(R72.DIAL,1.0)
PARAM(R71.DIAL,1.0)


and in the driver you have to specify an analog input:

NETLIST_ANALOG_INPUT(config, "maincpu:timer_pot1", "R71.DIAL");
NETLIST_ANALOG_INPUT(config, "maincpu:timer_pot2", "R72.DIAL");


and an input port:

PORT_START("POT_TIMER_1")
PORT_ADJUSTER( 1000, "Pot: Timer R71 Adjust" ) NETLIST_ANALOG_PORT_CHANGED("maincpu", "timer_pot1")
PORT_START("POT_TIMER_2")
PORT_ADJUSTER( 220, "Pot: Timer R72 Adjust" ) NETLIST_ANALOG_PORT_CHANGED("maincpu", "timer_pot2")


So I'm confused as to how the value given in the adjuster affects the POT2. Here I've given the one adjuster a value of 1000, and another a value of 220, how does that change the value, is it a percentage on scale of 0 to 100?

The dial setting in the param, is that an initial value?

==========================

I seem to be able to affect the pot value in-game make it count slower/faster, but the exact semantics are not quite understood.

============================

The UI not working properly with a slow netlist is getting problematic since half the time I can't even bring up the Sliders screen to change the values. Sometimes I can "kick it loose" by hitting ALT+ENTER to swap between full screen and window mode, but it still will hang up. (It will still respond to ALT+F4 and ALT+Enter). It seems like it won't respond to the up/down arrows until after a delay (like it needs the auto-repeat to kick in before it will see it). Does the input buffer get cleared before it can see the events or something?

I'm using Ubuntu, is this just a problem under linux?


one workaround I just figured out, put the netlist game into pause before bringing up the menu, then the menus work.
Posted By: =CO=Windler Re: Atari Lemans track roms - 07/04/22 03:42 AM
Originally Posted by Golden Child
Interesting stuff, CO, I was watching the moving pictures until I realized that you can auto translate the German captions into English.

Too bad they had that "youth protection law".

The last arcade videogame machine I saw in a German shopping center in Bremen was an Atari "Pole Position" cockpit at Horten that remained in operation likely until about 1992. But I also remember a Sega "Outrun" cockpit at Brinkmann that stood for few weeks in the computer department at the same time when they sold a PC with built-in Megadrive (looking like "Amstrad Mega PC" which was made 1993 - possibly rebranded as Compaq or such). It is unknown if there was a grace period for machines bought earlier or individual special approvals for non-violent games in some states of Germany.

The Nürburgring 3 graphics seems to be mostly described in the German language patent DE3243574A1 while the US patent is more general. The earlier Nürburgring 1 & 2 (which is mostly analogue without CPU) is described in patents US4077138, US4077138A. Unfortunately some of the old Foerst patents seem to be missing in online search. (I don't know if due to invention secrecy act if these included military simulators, but likely they were simply not scanned by Google when not found because these were expired anyway. The German ones tend to be OCR only, thus lacking illustrating drawings like schematics.)

There is a Foerst company history PDF (31MB huge) with plenty of fairly detailed info and many screenshots and newspaper articles of their historical arcade and professional driving simulators.

https://www.fahrsimulatoren.eu/images/pdf/Foerst-Firmenhistorie.pdf

Particularly the N6 graphics looks gorgeous. Unfortunately the screenshot dates seem partially messed up, and those dates in the youtube video got shuffled even worse and have nothing to do with the spoken text. Here is some additional driving simulator history:

Meet The Doctor-Engineer Who Basically Invented The Modern Racing Game
https://jalopnik.com/meet-the-doctor-engineer-who-basically-invented-the-mod-5906386

VW Invented First-Person Racing Video Games And They Don't Even Know It
https://jalopnik.com/vw-invented-first-person-racing-video-games-and-they-do-1671618942
Posted By: Golden Child Re: Atari Lemans track roms - 07/04/22 03:00 PM
Stunt Cycle is very similar to Gran Trak in many ways, thought I'd fiddle a little.

Attaching a clock to the score up counter and hacking a "force start" button gets you from 8 to 27 buses: (don't know what's happening with the ramps on score = 12)


Posted By: Golden Child Re: Atari Lemans track roms - 07/05/22 01:11 AM
Still trying to figure out why it isn't displaying the bike properly, but it's doing something...




I also wanted to figure out how the images look like in the rom:

There's 16 lines * 4 bytes wide * 4 images * 2 (frames of animation for each image) = 512 bytes.

Each bike is 3 bytes wide, the fourth byte is an image of the bus.

The bike is on the ground, half wheelie, full wheelie and crash.

Code
   
f = io.open("/mnt/z/mame/roms/stuntcyc/004275.f1","r")
a = f:read("*a")
function prtbyte(adr,a) if adr then io.write(string.format("%x",adr)..":") end for i=7,0,-1 do if (a & (2^i)) ~= 0 then io.write(i) else io.write(" ") end end end
 for r=0,7 do do for i=0,15 do for b = 0,2 do prtbyte(nil,a:byte((i|(r<<6)|(b<<4))+1)) end print() end  end end
                        
                        
                        
                        
                        
       076              
       07               
       076    10        
        765  2 07       
        76543   76      
     2 0 65     765     
   4   0765432 07 54 2  
      1       10   4    
   4 2107654321   5 3 1 
        7               
    3 1            4 2  
                        
                        
                        
                        
      107               
      10    32          
      107  4  1         
      10765    076 4    
       07     1  6      
       07654 2  7 5 3   
     2 0    3           
   4   07  4     6 4    
      1  65             
   4 2107               
        7               
    3 1                 
                        
                        
                        
                7 5     
   43    654321 7       
  54    7    2 0 6 4    
  543  0  54 2          
    3210 6  3   7 5     
     21 7  4            
      10  5             
    3 1  6              
      107               
   4  1                 
     2  7               
   4                    
     2 0                
                        
                        
                        
   4                    
 6   2                  
   4                    
 6   2                  
   4                    
    32107               
    3    654            
    3    6  3    6 4    
     2    5432107       
      107654321  6  3   
           43210 65     
           43       3   
          543   7 5     
                        
                        
                        
                        
                        
       076              
       07               
       076    10        
        765  2 07       
        76543   76      
    3 1  65     765     
       0765432 07 5 3   
   4  1 7     10  54  1 
     2107654321     3   
   4              5   1 
     2 0            3   
                        
                        
                        
                        
      107               
      10    32          
      107  4  1         
      10765    07 5     
       0      1 76  3   
       07654 2    5     
    3 1     3   7   3   
       0   4      5     
   4  1 765             
     2107               
   4                    
     2 0                
                        
                        
                        
                 6      
   43    65432107  4    
  54    7    2   6      
  543  0  54 2 0   4    
    3210 6  3    6      
     21 7  4            
      10  5             
     2 0 6              
   4  10                
      1 7               
   4 2                  
        7               
    3 1                 
         6 4            
       0    3           
       0  5 3           
       0  5 3           
        7 5432107       
          5432107       
          5432  7       
          5  2          
          5  2          
          5  2          
           4 2          
        7 543           
       0  54            
       0 6 4            
       0   4            
        7 5             
>  for r=0,7 do do for i=0,15 do for b = 3,3 do prtbyte(nil,a:byte((i|(r<<6)|(b<<4))+1)) end print() end  end end
        
        
        
        
        
        
        
        
  5432  
 6    1 
 6    1 
 654321 
 654321 
 6 43 1 
 654321 
 6    1 
        
        
        
        
        
        
        
        
  5432  
 6    1 
 6    1 
 654321 
 654321 
 654321 
 654321 
 6    1 

        
        
        
        
        
        
Posted By: Golden Child Re: Atari Lemans track roms - 07/05/22 08:23 AM
Okay, got the bike looking normal, still falling...




Don't know if this is right, but JD left a clue, saying that it could be DIRECTION_Q and it didn't look right until I used DIRECTION_Q.

Code
	TTL_7402_NOR(D4_3, DIRECTION_Q, H6)   // Schematic says DIRECTION, maybe DIRECTION_Q?
	TTL_7408_AND(B5_1, DIRECTION_Q, H5_AND_H6) // Schematic says DIRECTION, maybe DIRECTION_Q?
	TTL_7402_NOR(D4_4, D4_3.Q, B5_1.Q)

	TTL_7400_NAND(H2_1, HSYNC_Q, D4_4.Q)
	TTL_7400_NAND(H2_2, HSYNC_Q, H5)

   //"TTL_9322","+SELECT,+A1,+B1,+A2,+B2,+A3,+B3,+A4,+B4,+STROBE,@VCC,@GND")
	TTL_9322(J1, HSYNC, V4, P, V3, 4V, V2, 2V, V1, 1V, GROUND)

// 1V is from the VERTICAL COUNT registers (screen, used for bus images, read during hsync)
// V1 is from the VERTICAL MOTION registers (relative to the start of the cycle)

//  PROM_82S115(name, CE1Q, CE2, A0, A1, A2, A3, A4, A5, A6, A7, A8, STROBE)
	PROM_82S115(hf1, GROUND, P, A0, A1, A2, A3, A4, A5, A6, A7, A8, P)

	// 9 bits of rom addressing, 512 bytes
	ALIAS (A0, J1.Y4)  // image row number 0..15
	ALIAS (A1, J1.Y3)  
	ALIAS (A2, J1.Y2)
	ALIAS (A3, J1.Y1)
	ALIAS (A4, H2_2.Q)  // horiz byte number  0..3  (0-2 = bike 3 = bus)
	ALIAS (A5, H2_1.Q)  
	ALIAS (A6, R2)  // image number 0..3 (cycle angle)
	ALIAS (A7, R3)
	ALIAS (A8, R4)  // animation frame 0..1
	
	// R2 and R3 are CYCLE ANGLE CONTROL
	//
	// R2  R3
	//  0   0  both wheels on the road
	//  1   0  half wheelie   (held to a half wheelie while jumping)
	//  0   1  full wheelie
	//  1   1  crash / flipped position
	// depends on the throttle
Posted By: Golden Child Re: Atari Lemans track roms - 07/05/22 08:37 PM
Got the bike moving a little, found that the 9602 wasn't hooked up completely, causing the CYCLE_RESET signal not to fire.


NET_C(N6.16, VCC) // missing hookups to VCC and ground
NET_C(N6.8, GND)

Still some weirdness with horizontal counters, cant seem to move bike leftward.

Posted By: Just Desserts Re: Atari Lemans track roms - 07/05/22 09:08 PM
I guess Evel Knievel isn't being paid enough to actually jump the buses. smile
Posted By: =CO=Windler Re: Atari Lemans track roms - 07/06/22 07:41 AM
Is the chip (AY-3-8760?) inside the "Stunt Cycle" home console based on similar logic gate circuit or is it some kind of microcontroller?

https://handwiki.org/wiki/Software:Stunt_Cycle

I only find it mentioned here:
https://nerdstuffbycole.blogspot.com/2019/03/the-ay-3-8606-another-successfully.html

https://atariage.com/forums/topic/288619-tennis-a-pong-chip-port-to-the-intellivision/

I own the PAL version by Atari and a clone in a cartridge of Unimex Mark IX.
Posted By: Golden Child Re: Atari Lemans track roms - 07/06/22 09:09 AM
Yes, I think Evel's taken the day off, maybe it was Awful Knopfel...


====================================



Part of my debugging strategy is to use some printfs inside of a NETDEV_ANALOG_CALLBACK_MEMBER to see what's happening with the signals:


so I've got a NETLIST_ANALOG_OUTPUT which will call a NETDEV_ANALOG_CALLBACK_MEMBER:


inside stuntcyc_state I put:

Code
#define DEBUGNLAO(x,y) NETDEV_ANALOG_CALLBACK_MEMBER(update_##x) {printf("UPDATE " #x ": %f  "#x"= %f\n",time.as_double(),data); }

DEBUGNLAO(cyclereset,CYCLE_RESET)
DEBUGNLAO(cycleresetq,CYCLE_RESET_Q)
DEBUGNLAO(direction,DIRECTION)

#undef DEBUGNLAO



Then inside stuntcyc_state::stuntcyc(machine_config &config) you put:

Code
#define DEBUGNLAO(x,y) NETLIST_ANALOG_OUTPUT(config, "maincpu:"#x, 0).set_params(#y, FUNC(stuntcyc_state::update_##x));

DEBUGNLAO(cyclereset,CYCLE_RESET)
DEBUGNLAO(cycleresetq,CYCLE_RESET_Q)
DEBUGNLAO(direction,DIRECTION)


#undef DEBUGNLAO


You have to put a routine into two different locations in the code.

This way I can just copy and paste the same line DEBUGNLAO(cycleresetq,CYCLE_RESET_Q) and it will make the appropriate NETDEV_ANALOG_CALLBACK_MEMBER or NETLIST_ANALOG_OUTPUT.


so output looks like this:

UPDATE direction: 0.000000 direction= 0.100000
UPDATE cyclereset: 0.000000 cyclereset= 0.100000
UPDATE cycleresetq: 0.000000 cycleresetq= 0.100000
UPDATE cycleresetq: 0.000000 cycleresetq= 3.999999
UPDATE direction: 0.000000 direction= 3.999999




One thing that's interesting in the debugger, if you "gt 1" you can see the strip of screen that gets painted during the millisecond. It shouldn't be too hard to make it possible to step by less than a millisecond.

[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 07/06/22 10:18 AM
Info about the AY-3-8760:

https://atariage.com/forums/applications/core/interface/file/attachment.php?id=235064
Posted By: Just Desserts Re: Atari Lemans track roms - 07/06/22 10:26 AM
Originally Posted by =CO=Windler
Is the chip (AY-3-8760?) inside the "Stunt Cycle" home console based on similar logic gate circuit or is it some kind of microcontroller?

It's at least pretty certain it's not a microcontroller - microcontrollers that could actually do TV-based graphics didn't exist back then. There's no telling if it's based on "similar logic gate circuits" or not. It's an ASIC, all of the one-off TV game systems of that era were. It would require someone decapping such a chip and actually tracing out the silicon to work out an equivalent schematic to know anything more than that.
Posted By: Golden Child Re: Atari Lemans track roms - 07/08/22 09:02 AM
JD left another clue in the code:
Code
 // TTL_74193(name, A, B, C, D, CLEAR, LOADQ, CU, CD)
//	TTL_74193(L8, FIXED_RAMP_ZONE_Q, FIXED_RAMP_ZONE, P, P, JUMP_Q, LOAD_Q, P, GRAVITY) // Schematics say C and D should be to VCC - maybe ground instead?

// changed to GROUND and bike jumps!!!
	TTL_74193(L8, FIXED_RAMP_ZONE_Q, FIXED_RAMP_ZONE, GROUND, GROUND, JUMP_Q, LOAD_Q, P, GRAVITY) // Schematics say C and D should be to VCC - maybe ground instead?





I also tried to model a bunch of stuff that leads up to the SPEED_PULSES and up to R38 and R39 but it ran super slow...like over a minute to generate a single frame.
Posted By: Golden Child Re: Atari Lemans track roms - 07/15/22 03:02 AM
It's interesting to study the different Atari TTL games of this period as they have quite a bit of similarities.

I thought I'd try to figure out how the rom in tank works too:


Code

f = io.open("/mnt/z/mame/roms/tank/90-2006.k10","r")  a = f:read("*a")
function prtbyte(adr,a) if adr then io.write(string.format("%x",adr)..":") end for i=7,0,-1 do if (a & (2^i)) ~= 0 then io.write(i) else io.write(" ") end end end
function bit(x,y) return (x >> y) & 1 end

for score=0,63 do for v=0,7 do adr=((score<<3) | v | (1<<10)) io.write(score.." "..v..":") prtbyte(adr, a:byte(adr+1)) print() end end
for dir=0,31 do for v=0,7 do for h = 0,1 do adr=(v | bit(dir,4)<<3 | h<<4 | (dir & 0xf) << 5 | 1 << 10 | 1 << 9) prtbyte(nil,a:byte(adr+1)) end print() end print(string.rep("=",16))  end
for v=0,31 do for h=0,15 do adr=((v<<4) | h | (0<<9)) if h~=7 then prtbyte(nil,a:byte(adr+1)) end end print() end  -- playfield 0
for v=0,31 do for h=0,15 do adr=((v<<4) | h | (1<<9)) if h~=7 then prtbyte(nil,a:byte(adr+1)) end end print() end  -- playfield 1



Code
for v=0,31 do for h=0,15 do adr=((v<<4) | h | (0<<9)) if h~=7 then prtbyte(nil,a:byte(adr+1)) end end print() end  -- playfield 0
 6  3210 6       6 4     6 4   0 6 4  1  65   1  654  1 7     107  4  107  4  1 7 5   1 7 54  1 7 54   07 54    76      
76  321076  321 7 54321 7 5432 07 5432  7 5 32  7  432  7   3 10 6543 10 65432   65 32   6 432   6 432 0 6 4321  6  321 
7   3210                                          5 3 1 7 5 3                                                           
                  5432107654321076543210765432  7             1  6543210765432107654321076543                           
                                                                                                                        
        76543210765432107654321076543210765432107654321076543210765432107654321076543210765432107654321076      76543210
76543210        76                              7                  4                                    76              
76543210        76                              7                  4                                    76              
              1076                              7       7654       4             6                      76              
                76        5432107654                    7654                                3210        76              
                76        543210                             2                              3210        76              
                76        543210                 6                        5432              3210        76              
                76                                                 4      5432                          76              
                76         4                             6                5432                          76              
                76               6           2                                         0                76              
                76                                               6                                      76      76543210
                76                                 4                                                    76      76543210
                76              76543                      4                  1                         76      76543210
                76              765432107654                         2                    54321         76              
                76              765432107654         2                                    54321         76              
                76                             0                                    32107654321         76              
                76     0                                       0                                        76              
           4    76                                     0                                                76              
                76                     0                             2                                  76              
76543210        76        5432                   6                        54321076543                   76              
                76        5432                             4              54321076543                   76              
                76        5432                     4321         765          210                        76              
                76        5432        1076         4321         765          210            3           76       6543210
                76                    1076                      765                                     76              
                76                    1076                      765432                                  76              
                76                    1076                      765432                                  76              
7 5 3 10        765432107654321076543210765432107654321076543210765432107654321076543210765432107654321076              
> 



 for v=0,31 do for h=0,15 do adr=((v<<4) | h | (1<<9)) if h~=7 then prtbyte(nil,a:byte(adr+1)) end end print() end
 6  3210 6       6 4     6 4   0 6 4  1  65   1  654  1 7     107  4  107  4  1 7 5   1 7 54  1 7 54   07 54    76      
76  321076  321 7 54321 7 5432 07 5432  7 5 32  7  432  7   3 10 6543 10 65432   65 32   6 432   6 432 0 6 4321  6  321 
7   3210                                          5 3 1 7 5 3                                                           
                  5432107654321076543210765432  7             1  6543210765432107654321076543                           
                                                                                                                        
        76543210765432107654321076543210765432107654321076543210765432107654321076543210765432107654321076      76543210
76543210        76                                    10                      10                        76              
76543210        76                                    10                      10                        76              
                76                                    10                                                76              
                76        5432107654                  10            3210                765432          76              
                76              7         54                 2        10                                76              
                76              7         54     6                    10      10                        76              
                76                        54                       4                      543   7   3   76              
                76                                       6                                54            76              
                7654321076                   2                        1076          32107654            76              
                76                                               6    10                                76      76543210
                76                  32107654       4                  10                                76      76543210
                76                        54               4                                  1076543   76      76543210
                76                        54                         2                        10        76              
                76      76543210                     2                           6543210   43210        76              
                76                             0                                                        76              
                76                                             0        76543210                        76              
           4    76                54                   0                                                76              
                76    107654      54      54                         2                  76              76              
76543210        76        54              54     6                                      76              76              
                76        54              54               4          10                76              76              
                76                        5432        10        76543210      10                        76              
                76                                              76            10                        76       6543210
                76                               65                           10              10        76              
                76            10                                                              10        76              
                76            10                      10                                      10        76              
7 5 3 10        765432107654321076543210765432107654321076543210765432107654321076543210765432107654321076           



0 0:400:        
0 1:401:     210
0 2:402:     2 0
0 3:403:     2 0
0 4:404:     2 0
0 5:405:     2 0
0 6:406:     2 0
0 7:407:     210
1 0:408:        
1 1:409:     21 
1 2:40a:      1 
1 3:40b:      1 
1 4:40c:      1 
1 5:40d:      1 
1 6:40e:      1 
1 7:40f:     210
2 0:410:        
2 1:411:     210
2 2:412:     2 0
2 3:413:       0
2 4:414:     210
2 5:415:     2  
2 6:416:     2  
2 7:417:     210
3 0:418:        
3 1:419:     210
3 2:41a:     2 0
3 3:41b:       0
3 4:41c:      10
3 5:41d:       0
3 6:41e:     2 0
3 7:41f:     210
4 0:420:        
4 1:421:     2  
4 2:422:     2 0
4 3:423:     2 0
4 4:424:     2 0
4 5:425:     210
4 6:426:       0
4 7:427:       0
5 0:428:        
5 1:429:     210
5 2:42a:     2  
5 3:42b:     2  
5 4:42c:     210
5 5:42d:       0
5 6:42e:     2 0
5 7:42f:     210
6 0:430:        
6 1:431:     210
6 2:432:     2 0
6 3:433:     2  
6 4:434:     210
6 5:435:     2 0
6 6:436:     2 0
6 7:437:     210
7 0:438:        
7 1:439:     210
7 2:43a:     2 0
7 3:43b:       0
7 4:43c:       0
7 5:43d:       0
7 6:43e:       0
7 7:43f:       0
8 0:440:        
8 1:441:     210
8 2:442:     2 0
8 3:443:     2 0
8 4:444:     210
8 5:445:     2 0
8 6:446:     2 0
8 7:447:     210
9 0:448:        
9 1:449:     210
9 2:44a:     2 0
9 3:44b:     2 0
9 4:44c:     210
9 5:44d:       0
9 6:44e:     2 0
9 7:44f:     210
10 0:450:        
10 1:451: 65  210
10 2:452:  5  2 0
10 3:453:  5  2 0
10 4:454:  5  2 0
10 5:455:  5  2 0
10 6:456:  5  2 0
10 7:457: 654 210





      1076      
       07       
 6543  07  4321 
 65432107654321 
 65432107654321 
 65432107654321 
 6543      4321 
                
================
        76543   
         65     
  5432  76  3210
  5432107654321 
 65432107654321 
 6543210765432  
76543     5432  
                
================
         65432  
   4321   54    
  54321  65   10
  54321076543210
 65432107654321 
7654     65432  
         6543   
                
================
           432  
   43210   43210
  54321   54    
 6543210765  210
7654321076543210
765     7654321 
         65432  
        76543   
================
     210   43   
   43210   43210
 654321  654    
76543210765  210
765   1076543210
        765432  
       07654    
       076      
================
      107       
   4321076  321 
76543210   43210
 65432107654    
     210765 3210
      1076543210
    321076543   
     21076      
================
      1076      
 654321076   21 
 65432107   3210
    321076543 10
     210765     
     21076543   
   4321076543   
    3210        
================
       07654    
 65432107654    
 654321076    10
     21076543210
     21076    10
     21076543   
   4321076543   
    32107       
================
                
  5432107654    
  5432107654    
    321076    10
    321076543210
    321076    10
  5432107654    
  5432107654    
================

Posted By: Golden Child Re: Atari Lemans track roms - 07/15/22 09:29 AM
So one of the things that had me baffled about tank was figuring out how it handles the mines. Specifically, how does it keep track of whether a mine has been hit or not?

It doesn't have a cpu, and it only has a ROM chip, no ram chips, so how does it know if a mine has been hit?

There's a dual 8 bit shift register, the Signetics N8277, that is used as a 16 bit shift register and that's enough to hold 1 bit of state for each mine.

In the playfield, there's a rectangular region defined for the mines, any bit that's set in this region will be a mine, but we're only allowed 1 mine per row.

When the game starts, the shift register is cleared, a 1 bit means that the mine has been hit.


As the playfield gets scanned vertically, this shift register gets cycled through and updated, collision with either tank1 or tank2 will remove the mine (set the bit to 1 that will get shifted in on the next clock).
The D0A and D1A are set so that it inverts the input DSA on pin 4.


[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 07/15/22 08:06 PM
I managed to get one of the tanks displaying. It's super hacky but at least it shows something.

There's something very very wrong with one of the 74107's. Hooked up normally, IC_N1.6 GOES TO IC_M1.4 but for some reason, it never gets updated. If I put a debug net list analog output on IC_N1.6, it never gets updated, however if I put a debug net list analog output on IC_N1.5, it magically starts updating??? If it never updates properly THR1Q and THW1Q don't activate and the display window doesn't get activated.

Here you see a tank in the lower right, it jumps all around:
[Linked Image from i.imgur.com]

Got both tanks appearing, but jumping all over the place:
[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 07/16/22 12:07 PM
Another question was where does the explosion graphic come from?

It isn't in the rom, so where does it originate?

It comes from a bunch of XOR and NOR and NAND logic that generates an image based on the horizontal and vertical coordinates.

[Linked Image from i.imgur.com]

A couple of screenshots from a youtube video of kee tank (the machine in the video has a color mod)

[Linked Image from i.imgur.com][Linked Image from i.imgur.com]

So let's make a PCBASIC program (GWBasic interpreter that is ubuntu package python3-pcbasic) that will render our explosion:

I hate basic boolean logic semantics like -1 for positive, so I made some more c-like boolean operations with DEF FN:

Code
10 DIM A(5000),B(5000)
50 DEF FN cnot(xarg)=(xarg=0)*-1
60 DEF FN cbool(xarg)=(xarg<>0)*-1
70 DEF FN bit(xarg,yarg)=fn cbool( xarg and (2^yarg))
80 def fn cxor(xarg,yarg)=fn cbool(fn cbool(xarg) xor fn cbool(yarg))
90 DEF FN cnand(xarg,yarg)=fn cbool(fn cnot(fn cbool(xarg) and fn cbool(yarg)))
91 DEF FN cnor(xarg,yarg)=fn cbool(fn cnot(fn cbool(xarg) or fn cbool(yarg)))
100 SCREEN 7 : rem screen 2 too much resolution
101 SIZE=16
105 FOR FLASH = 0 TO 1
110 FOR X = 0 TO SIZE-1
120 FOR Y = 0 TO SIZE-1
130 P = FN cnand ( FN cxor( FN cxor( FN cxor(FN bit(y,2),FN bit(y,3)), FN cxor(FN bit(x,2),FN bit(x,3))), flash), FN cnor(  FN cxor( FN bit(y,1),FN bit(x,1)), FN cnor(  FN cxor(FN bit(x,2),FN bit(x,3)), FN cxor(FN bit(y,2),FN bit(y,3)) ) )  ) 
140 PSET(X,Y),FN CNOT(P)*4
150 NEXT : NEXT
155 IF FLASH = 0 THEN GET (0,0)-(SIZE-1,SIZE-1),A ELSE GET(0,0)-(SIZE-1,SIZE-1),B
160 NEXT
200 FOR I = 1 TO 500
210  FLASH = I MOD 2
220 IF FLASH = 1 THEN PUT(160-(size/2),100-(size/2)),A,PSET ELSE PUT (160-(size/2),100-(size/2)),B,PSET
225 FOR DELAY = 1 TO 10000:NEXT
230 NEXT


[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]

And why not render a larger area just to see the repeated pattern:

[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 07/16/22 04:55 PM
And where to do the mine X images come from?

[Linked Image from i.imgur.com]


So modifying my PCBASIC program you can see the mine image, what's kind of interesting is that it doesn't occupy the entire 16x16 area, just the lower right 8x8.

Code

10 DIM A(5000),B(5000)
50 DEF FN cnot(xarg)=(xarg=0)*-1
60 DEF FN cbool(xarg)=(xarg<>0)*-1
70 DEF FN bit(xarg,yarg)=fn cbool( xarg and (2^yarg))
80 def fn cxor(xarg,yarg)=fn cbool(fn cbool(xarg) xor fn cbool(yarg))
90 DEF FN cnand(xarg,yarg)=fn cbool(fn cnot(fn cbool(xarg) and fn cbool(yarg)))
91 DEF FN cnor(xarg,yarg)=fn cbool(fn cnot(fn cbool(xarg) or fn cbool(yarg)))
100 SCREEN 7 : rem screen 2 too much resolution
101 SIZE=16
105 FOR FLASH = 0 TO 1
110 FOR X = 0 TO SIZE-1
120 FOR Y = 0 TO SIZE-1
130 P = FN cnand ( FN cxor( FN cxor( FN cxor(FN bit(y,2),FN bit(y,3)), FN cxor(FN bit(x,2),FN bit(x,3))), flash), FN cnor(  FN cxor( FN bit(y,1),FN bit(x,1)), FN cnor(  FN cxor(FN bit(x,2),FN bit(x,3)), FN cxor(FN bit(y,2),FN bit(y,3)) ) )  ) 
140 PSET(X,Y),FN CNOT(P)*4
150 NEXT : NEXT
155 IF FLASH = 0 THEN GET (0,0)-(SIZE-1,SIZE-1),A ELSE GET(0,0)-(SIZE-1,SIZE-1),B
160 NEXT
200 FOR I = 1 TO 500
210  FLASH = I MOD 2
220 IF FLASH = 1 THEN PUT(160-(size/2),100-(size/2)),A,PSET ELSE PUT (160-(size/2),100-(size/2)),B,PSET
225 FOR DELAY = 1 TO 10000:NEXT
230 NEXT



130 F13.11 = FN CXOR( FN BIT(X,1), FN BIT(X,2) ) : F13.8= FN CXOR( FN BIT(Y,1), FN BIT(Y,2) ) : F13.6 = FN CXOR( F13.8, F13.11) : A10.11= FN CNAND( FN BIT(Y,3), FN BIT(X,3) ) : D7.02 = FN CNOR( A10.11, F13.6) : P = D7.02
140 PSET(X,Y),FN CBOOL(P)*4

[Linked Image from i.imgur.com]
If I change the colors a little, you can see it only occupies the lower right quadrant.
[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 07/17/22 10:21 PM
I got tired of having to put the same DEBUGNLAO in two places, so why not put it in an include file?

inside class tank_state : public driver_device

Code
#define DEBUGNLAO(x,y) NETDEV_ANALOG_CALLBACK_MEMBER(update_##x) {printf("UPDATE " #x ": %f  "#x"= %f\n",time.as_double(),data); }
#include "nlao.h"
#undef DEBUGNLAO


inside void tank_state::tank(machine_config &config)

Code
#define DEBUGNLAO(x,y) NETLIST_ANALOG_OUTPUT(config, "maincpu:"#x, 0).set_params(#y, FUNC(tank_state::update_##x));
#include "nlao.h"
#undef DEBUGNLAO

and then in nlao.h I put the things I want to watch:

Code
DEBUGNLAO(fire1,FIRE1)
DEBUGNLAO(shell1,SHELL1)
DEBUGNLAO(c9_14,IC_C9.14)
DEBUGNLAO(c9_13,IC_C9.13)
DEBUGNLAO(c9_15,IC_C9.15)
DEBUGNLAO(c9_11,IC_C9.11)


I tried everything I could think of to make the tanks stop jumping around, finally I figured that if you hardwire the stop code to the counter you can make it stop:

These values were found by experimentation:

Horizontal load: I think it should be 0x78 but seems to hold steady if I load it with 0x7c. (0x400 - 0x78 = 904) (0x400 - 0x7c = 900)

NET_C(GND, IC_A1.3)
NET_C(GND, IC_A1.4)
NET_C(P, IC_A1.5)
NET_C(P, IC_A1.6)

Vertical load:
I think it should be 0xdf8, but it seems to stop moving if I load it with 0xdf7
(0x1000-0xdf8 = 520) (0x1000-0xdf7 = 521)

NET_C(P, IC_A2.3)
NET_C(P, IC_A2.4)
NET_C(P, IC_A2.5)
NET_C(GND, IC_A2.6)

The reason the right tank moves up and down is that I fixed the horizontal load but not the vertical load.



No matter what I try, I can't seem to make the 9602 fire.
Posted By: Golden Child Re: Atari Lemans track roms - 07/19/22 08:10 PM
Took a look at some of the other atari ttl games and it's super cool that a lot of them have detailed manuals. It's useful to read other manuals for the mechanics of each of these games have significant similarities.

I got interested in Atari Anti aircraft and it looks very doable. It seems a bit simpler than other games, so I'll see if I can make it work with netlist.

It only has one rom for the aircraft and a UFO
Code
> for i=0,#d-1 do prtbyte(i,d:byte(i+1)) print() end
0:   43210
1:  5   1 
2:  5  2  
3:  5 3   
4:  5 3   
5:  5 3   
6:  5 3   
7:  543   
8:  543   
9:  54 2  
a:  54 2  
b:  54    
c:  5 3   
d:  5 3   
e:   4    
f:   4    
10:        
11:   43   
12:   43   
13:   43   
14:  543   
15: 6 432  
16: 6543 1 
17: 6 43  0
18: 6543  0
19: 6 43  0
1a: 6543 1 
1b: 6 432  
1c:  543   
1d:   43   
1e:   43   
1f:   43   


It's quite interesting to study the history of Atari TTL games, turns out there was a company called Fun Games Inc. that copied Atari's Tank game

from http://www.atarihq.com/pongtest/aboutbreakout.php
Quote
Engineering started on the concept as well as several other games, including a new military game called Jet Fighter by Lyle Rains. Unfortunately during the process, several of the engineers became disillusioned with Atari and the management and thought they could do a better job. Taking plans and parts from Atari, they started up their own company - Fun Games, Inc.

With the plans and parts stolen, Fun Games released an exact copy of Bristow's Tank by the end of the year, even calling it Tankers. But it was the game announced that year and another released next year that proved their downfall. Released at the same time as Tankers, Take 7 was a compendium of six of Atari's previous PONG efforts and included one extra game called "Bust Out", where a player used a paddle and ball to break through a multi-segmented wall. Bust Out was in fact Breakout. In 1976 they released Race!, a copy of Gran Trak 10, and Biplane, a copy of Lyle's just released Jet Fighter that replaced the jets with biplanes. Atari had enough and sued Fun Games over the Jet Fighter rip off, with Steve Bristow and others testifying. Easily winning the suit, 1976 was the last year a game with the Fun Games banner was released. The damage was done however, and development on Breakout had been stalled during the process.
Posted By: Golden Child Re: Atari Lemans track roms - 07/21/22 07:08 AM
Got the Antiairc score working and the launchers showing. Don't know why there's 3 vertical copies though.

Finally figured out what "Display Monitor Sliders" does in the Machine Configuration for fixed frequency monitors: It will ignore the sliders when this is set to off.

The score display circuit in stunt cycle and antiairc are very similar, however, stunt cycle uses the YQ output and antiairc uses the Y output. That took me a while to realize what was wrong.

Posted By: Al Kossow Re: Atari Lemans track roms - 07/21/22 02:43 PM
There may be a Fun Games Biplane rom around.
I thought I remember having a board set.

I also still have a PSE Game Tree board set I need to dump.
Posted By: Golden Child Re: Atari Lemans track roms - 07/21/22 06:51 PM
Looking around I think there's a dump of biplane in src/mame/misc/fungames.cpp,

I think there's also one of gametree in src/mame/misc/pse.cpp

There's a manual for gametree and it looks interesting.
Posted By: Golden Child Re: Atari Lemans track roms - 07/24/22 05:19 PM
Looking at the roms for outlaw and qwak:
Code
out = io.open("/mnt/z/mame/roms/outlaw/0003323.j4","r") o = out:read("*a")
function prtbyte(adr,a) if adr then io.write(string.format("%x",adr)..":") end for i=7,0,-1 do if (a & (2^i)) ~= 0 then io.write(i) else io.write(" ") end end en
for image=0,7 do for line=0,31 do for lr=0,1 do adr=line | lr << 5 | image << 6 prtbyte(nil,o:byte(adr+1)) end print() end end
7654321076543210
7654321076543210
765432  76543210
7654      543210
765432  76543210
765432  76543210
765432 076543210
76543    6543210
7654      543210
7654       43210
765  2      3210
765 32    5  210
765 32    54 210
765 32    54 210
765 32    54 210
765 3     543210
76543     543210
76543  0  543210
76543  0  543210
7654   0  543210
7654  10  543210
7654  10  543210
7654  10  543210
76543  0  543210
76543     543210
765432    543210
765432    543210
765432 0 6543210
76543 10 6543210
76543210 6543210
7654321076543210
7654321076543210
7654321076543210
76 43 1076543210
7    21076543210
76  321076543210
76 4321076543210
7 543210765 3210
76543210765 3210
765  210765 3210
765   10765 3210
7654  1076  3210
76543      43210
7 543     543210
7 54     6543210
7 5      6543210
7   3    6543210
76543    6543210
76543    6543210
76543    6543210
76543     543210
7  43      43210
76 43   7    210
76 432  76    10
765432   654  10
7654321  654  10
7654321  654  10
7654321  654  10
7654321  654  10
765432  7654  10
765432  76543 10
765432 0765432 0
765432 076543210
7654321076543210
76543210765432 0
7   3 1 76   2 0
76 43 1 765 32 0
76 43 1 765 3210
76 43 1   5 32 0
7654321076543210
7654321076543210
7654321076543210
7654321   543210
7654321   543210
7654321   543210
7654321   543210
7654321   543210
765432     43210
765432     43210
765432 0 6 43210
76543  0 6  3210
7654  10 65  210
765   10 65   10
76  3210 6543  0
7654321076543210
7654321076543210
7654321076543210
7654321076543210
      1   5   1 
 6 4 21 7 5 3 1 
   4 21   5   1 
 6 4 21 7 5  21 
 6 4 21 7 5 3 1 
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
76543  076543210
765      6543210
76543  076543210
76543  076543210
76543 1076543210
765    076543210
76      76543210
7        6543210
7         543210
7      0  543210
765    07 543210
765     7  43210
765      6  3210
765  21   543210
765  210   43210
7654  107  43210
7654  10   43210
7654  10  543210
765  210 6543210
76  3210 6543210
76 432107 543210
76 4321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654321076543210
7654  1076543210
76      76543210
7654  1076543210
7654  1076543210
76543  076543210
76543     543210
7 543   7  43210
7  43     543210
76       6543210
7654     6543210
76543    6543210
7654      543210
76        543210
7     10  543210
7   3210  543210
76  3210   43210
76  32107  43210
76   2107   3210
765  21076   210
765  210765   10
765  2107654   0
765  21076543  0
76   210765432 0
76543210765432 0
7654321076543210

...3 more running images...



qwfile = io.open("/mnt/z/mame/roms/qwakttl/90-2002.9k","r") q = qwfile:read("*a") print(#q)
hlist = { 0, 3, 2, 1}
for image=0,7 do for line=0,15 do for h=0,3 do adr = line| hlist[h+1] <<6 | (image&3) <<4 | ((image&4)>>2) << 8 prtbyte(nil,q:byte(1+adr ))end  print() end end
                                
                                
                                
               0                
 654          107         543210
   432107    21076    1076543   
     210765432  7 543210765     
        7654321076543210        
           432107654            
               07               
                7               
                7               
                                
                                
                                
                                
                                
                                
                                
                                
                                
    32         0         654    
     21076    107   321076      
        76543210765432          
           432107654            
               07               
                7               
                                
                                
                                
                                
                                
                                
               0                
              107               
             2107654            
         65432  7 54321         
        7654321076543210        
       0765432107654321076      
      1076     07     10765     
     2107       7       7654    
    321         7        654    
    321                   543   
   43                      43   
   43                       32  
  54                         2  
                                
                                
                                
                                
                                
                                
               07               
            32107654            
           4321076543           
          543210765432          
         6543   7   321         
        765     7    210        
        76            10        
       07              07       
      10                76      
                         6      
                                
                                
                                
               0 6              
            3  0 6  3           
            3 10765 3           
            3 10765 3           
            3 10765 3           
            3 10765 3           
            321076543           
             2107654            
              10765             
               076              
                7               
               076              
               076              
                7               
                7               
                                
      107                       
    321076                      
    3210765                     
      10765432107654321         
       07654321076543210765432  
        7654321076543210765     
        7654321076543210        
        76543210765432107       
       0765432107654321076      
      10765           10765     
     210                  543   
    32                       2  
  54                            
                                
                                
                                
           43              43   
           4321            4321 
          54              54    
         65              65     
        76              76      
       076             076      
     21076           21076      
    321076          321076      
   4321076         4321076      
 654321076       654321076      
 65432107        65432107       
  543210          543210        
    3 1             3 1         
    32107           32107       
                                
                                
                                
       076                      
      107654321076543           
     2107654321076543210765432  
     2107654321076543210765     
         6543210765432107       
          5432107654321         
          543210765432          
           432    543           
            321   54            
             21  65             
              1 76              
              107               
               07               
                                


Posted By: Golden Child Re: Atari Lemans track roms - 07/27/22 12:47 AM
Playing with shark jaws roms:
Code
sharkf = io.open("/mnt/z/mame/roms/sharkjaws/004182.da1","r") s = sharkf:read("*a") print(#s)
sharkf2 = io.open("/mnt/z/mame/roms/sharkjaws/004183.db1","r") s2 = sharkf2:read("*a") print(#s2)

function prtbytewide(adr,a,wide) if adr then io.write(string.format("%x",adr)..":") end for i=7,0,-1 do for dup = 1,wide do if (a & (2^i)) ~= 0 then io.write(i) else io.write(" ") end end end end

for image = 0,1 do for line=0,15 do for h = 0,3 do adr = h<<5 | line<<1 | image << 7   prtbytewide(nil, s:byte(adr+1) << 4| s:byte(adr+1+1) << 0, 4) end print() end end  -- shark
for image = 0,1 do for line=0,15 do for h = 0,3 do adr = h<<5 | line<<1 | image << 7   prtbytewide(nil, s2:byte(adr+1) << 4 | s2:byte(adr+1+1)<<0,2 ) end print() end end  -- diver

Code
> for image = 0,1 do for line=0,15 do for h = 0,3 do adr = h<<5 | line<<1 | image << 7   prtbytewide(nil, s:byte(adr+1) << 4| s:byte(adr+1+1) << 0, 4) end print() end end  -- shark
                                        5555                                                                                    
                                        55554444                                                                                
                                        555544443333                                                                            
                                        55554444    2222                                                                        
7777                                    55554444333322221111                                                                    
7777                            7777666655554444333322221111000077776666                        7777            33332222        
77776666                111100007777666655554444333322221111000077776666555544443333            77776666    44443333    1111    
777766665555        222211110000777766665555444433332222111100007777    55554444333322221111    77776666555544443333222211110000
77776666555544443333222211110000777766665555444433332222111100007777666655554444333322221111000077776666    44443333222211110000
77776666555544443333222211110000                            00007777            333322221111    7777            333322221111    
777766665555444433332222111100007777666655554444333322221111000077776666            2222                                        
7777666655554444333322221111000077776666555544443333222211110000777766665555                                                    
77776666                    0000777766665555444433332222111100007777666655554444                                                
7777                            7777666655554444333322221111000077776666555544443333                                            
7777                                                                                                                            
                                                                                                                                
                                        5555                                                                                    
                                        55554444                                                                                
                                        555544443333                                                                            
                                        5555444433332222                                                                        
    6666                                55554444333322221111                                                                    
    6666                        7777666655554444333322221111000077776666                        7777            33332222        
    66665555            11110000777766665555444433332222111100007777666655554444                77776666    44443333    1111    
    666655554444    222211110000777766665555444433332222111100007777    555544443333            77776666555544443333222211110000
    6666555544443333222211110000777766665555444433332222111100007777666655554444333322221111    77776666    44443333222211110000
    6666555544443333222211110000                            000077776666    444433332222111100007777            333322221111    
    666655554444333322221111000077776666555544443333222211110000777766665555    333322221111                                    
    6666555544443333222211110000777766665555444433332222111100007777666655554444    2222                                        
    66665555                00007777666655554444333322221111000077776666555544443333                                            
    6666                        777766665555444433332222111100007777666655554444                                                
    6666                                                                                                                        
                                                                                                                                
> 
> 
> 
> for image = 0,1 do for line=0,15 do for h = 0,3 do adr = h<<5 | line<<1 | image << 7   prtbytewide(nil, s2:byte(adr+1) << 4 | s2:byte(adr+1+1)<<0,2 ) end print() end end  -- diver
                                                                
                                                                
          22                                                    
        33  11    6655443322110077    443322                    
      44      00  66554433221100776655443322                    
                77  554433221100776655443322                    
                  6655443322110077    4433                      
                      44        77          11                  
                    55          77        22                    
                  66              66    33                      
      44        77                  5544                        
    55  33221100                    55                          
          22                      66                            
                                7766                            
                              00    55                          
                                                                
                                                                
                                                                
                                                                
                  6655443322110077    443322                    
                  66554433221100776655443322                    
      44            554433221100776655443322                    
    55  33221100776655443322110077    4433                      
  66                55          77                              
      44          66            77        22                    
    55  3322110077              77      33                      
  66                              66  44                        
                                    55                          
                                  66                            
                                77                              
                              0077                              
                            11    66                            
> 
Posted By: Golden Child Re: Atari Lemans track roms - 07/29/22 07:22 PM
I came across a Computer Space service manual. I like this in the beginning of the manual:

Call me personally...

[Linked Image from i.imgur.com]



This was on one of the schematic pages:

[Linked Image from i.imgur.com]
Posted By: Golden Child Re: Atari Lemans track roms - 08/21/22 12:46 PM
After much fiddling, I finally got a "proper" image to display for Outlaw (at least the score numbers and the bar down at the bottom):

[Linked Image from i.imgur.com]


This was pretty frustrating to figure out.

The problem lay in the 74107 netlist. When the counter hits 256 + 128 + 64 + 4 + 1 = 453, it's supposed to set HRESET. This makes HRESETQ low which is supposed to clear the 74107 F3. The HRESETQ clears F3, but the falling 128H that clocks F3 sets the 256H.

[Linked Image from i.imgur.com]

Modifying nld_74107.cpp a bit to check the m_clrQ():


NETLIB_HANDLERI(clk)
{
const netlist_sig_t J(m_J());
const netlist_sig_t K(m_K());
const netlist_sig_t t(m_Q.net().Q());

if (!m_clrQ()) newstate(0);
else if (J & K) newstate(t ^ 1);
else if ((J | K)^1) NULL;
else newstate(J);

// m_clk.inactivate();
// newstate(((t ^ 1) & J) | (t & (K ^ 1)));
}


Before that change I would get only about half of the screen since the HRESET would trigger prematurely:

[Linked Image from i.imgur.com]

In the schematic, there's a resistor R13 that has a value of 10 ohms that's hooked to 5V. That seems way too low. Making R13 have a value of 10K ohms it seems to work better. The 10 ohms value is repeated in the parts list as well.
Posted By: Golden Child Re: Atari Lemans track roms - 08/25/22 04:35 PM
According to the Outlaw manual, it says that the HSYNC should be about 64 microseconds and the VSYNC should be 16.7 milliseconds. Also the VSYNC should be equal to 4 horizontal lines.

[Linked Image from i.imgur.com]

So let's change our debug net list function to track the amount of time between changes:

We'll use a couple of static variables to hold the previous times, so we can track the 2 most recent changes.

Code
//#define DEBUGNLAO(x,y) NETDEV_ANALOG_CALLBACK_MEMBER(update_##x) { printf("UPDATE " #x ": %f  "#x"= %f\n",time.as_double(),data); }
#define DEBUGNLAO(x,y) NETDEV_ANALOG_CALLBACK_MEMBER(update_##x) { static double last0 = 0.0; static double last1 = 0.0; printf("UPDATE " #x ": %f  "#x"= %f    delta=%f  delta2=%f\n",time.as_double(),data,time.as_double()-last0,time.as_double()-last1); last1 = last0; last0 = time.as_double();  }

and we'll track just the HSYNC and VSYNC signals:

Code
DEBUGNLAO(hsync, HSYNC)
DEBUGNLAO(vsync, VSYNC)


Code
UPDATE hsync: 0.988522  hsync= 3.999999    delta=0.000060  delta2=0.000064  <<< hsync lasts 64 usec
UPDATE hsync: 0.988527  hsync= 0.100000    delta=0.000004  delta2=0.000064
UPDATE vsync: 0.988584  vsync= 3.999999    delta=0.016496  delta2=0.016751   <<< vsync is .016751 or approx 16.7 msec
UPDATE hsync: 0.988586  hsync= 3.999999    delta=0.000059  delta2=0.000064
UPDATE hsync: 0.988591  hsync= 0.100000    delta=0.000004  delta2=0.000064
UPDATE hsync: 0.988650  hsync= 3.999999    delta=0.000060  delta2=0.000064
UPDATE hsync: 0.988654  hsync= 0.100000    delta=0.000004  delta2=0.000064
UPDATE hsync: 0.988714  hsync= 3.999999    delta=0.000059  delta2=0.000064
UPDATE hsync: 0.988718  hsync= 0.100000    delta=0.000004  delta2=0.000064
UPDATE hsync: 0.988778  hsync= 3.999999    delta=0.000059  delta2=0.000064
UPDATE hsync: 0.988782  hsync= 0.100000    delta=0.000005  delta2=0.000064
UPDATE vsync: 0.988840  vsync= 0.100000    delta=0.000256  delta2=0.016751  <<< vsync lasts .000256 or 4 * .000064
UPDATE hsync: 0.988842  hsync= 3.999999    delta=0.000059  delta2=0.000064

so it looks like it's doing the correct thing.


Next up is to write something to handle a 74195 shift register which is used to handle the outlaw status.

Posted By: Golden Child Re: Atari Lemans track roms - 08/30/22 05:21 PM
I keep adding a little bit more and a little bit more, and now it shows the "outlaw" as a block that moves and shoots (the flickering square). For some reason, the rom isn't reading properly yet to get the proper outlaw picture. I do like the smooth motion of the block.


Super exciting, I know... 8-)





It kinda baffled me how the lightgun worked, but after watching a video of outlaw you can see the whole screen flash when the trigger is pressed. I still have to hook up the FLASH.

My strategy is to add a section of the circuit at a time and "alias" the parts that aren't actually hooked up since it's easier to get it compiling and running that way. It's so easy to make typos and since netlist exits after a single error, you have to fix, compile, and run for each one.

My favorite error is when I invert the order of ALIASES, putting the second part first. I seem to do that a lot.


As it gets properly hooked up, I comment out the aliases, usually after netlist says "you've already defined that."

// ALIAS(BADGUYQ, P)
ALIAS(FLASHQ, P)
// ALIAS(EXPLOSIONQ, P)
// ALIAS(SHOTQ, P)
// ALIAS(COMPWINDOW, GND)
Posted By: Golden Child Re: Atari Lemans track roms - 08/31/22 11:36 AM
Kept looking at why I wasn't getting any images out of the rom.

I copied JD's MK28000 function and made a SIGNETICS_8205 512 byte rom, and changed a bunch of stuff around. For the tristate outputs I changed the variable names and the logic around, but didn't update the variable that controls the tristate output, so it was never outputting any data.

For some reason, netlist hates a tristate output that isn't connected to anything (actually it is connected to 74194 shift registers):

Quote
Netlist CPU Device device 'maincpu': netlist ERROR: Tristate output J4.O8 on device J4 is not connected to a proxy. You need to set parameter FORCE_TRISTATE_LOGIC for device J4 if tristate enable inputs are all connected to fixed inputs. If this is not the case: Review your netlist. Something is wrong.

My workaround is to hook it to a "dummy" resistor with high resistance connected to ground or 5v. That seemed to quiet the errors.

I'm glad that I initially connected the dummy resistor to GND instead of 5V, because without the tristate rom working I could see a black rectangular block where the graphics data should be. Changing that to 5v made the rectangular block invisible.

Code
	RES(OUT1R, 1e9)
	NET_C(J4.O1, OUT1R.1)
	NET_C(OUT1R.2, GND)

That seems like a lot to type, why not try a macro:
Code
#define DUMMYRESISTOR(CHIP,PIN)  RES(CHIP##PIN##DUMMY, 1e9) NET_C(CHIP##PIN##DUMMY.1, CHIP.PIN) NET_C(CHIP##PIN##DUMMY.2, GND)

DUMMYRESISTOR(J4, O1)
DUMMYRESISTOR(J4, O2)
DUMMYRESISTOR(J4, O3)
DUMMYRESISTOR(J4, O4)
DUMMYRESISTOR(J4, O5)
DUMMYRESISTOR(J4, O6)
DUMMYRESISTOR(J4, O7)
DUMMYRESISTOR(J4, O8)


Skip to 1:34 for the running outlaw:

Posted By: Golden Child Re: Atari Lemans track roms - 08/31/22 07:27 PM
Wanted to see if he could run left and right so I setup a clock to flip the direction every 10 seconds since actionreset isn't working for some reason.

Posted By: Golden Child Re: Atari Lemans track roms - 09/02/22 03:43 PM
Hooked up a trigger, now you can see gun flashes and an explosion. The explosion appears in the same spot in the upper left since I'm just hooking the GUNOUTPUT to the trigger for testing. Now I've gotta figure out how PORT_CROSSHAIR inputs work, so I'm studying operation wolf.

Adding the logic for the start button and this seems to have sped up the action clock for the outlaw.

Posted By: Golden Child Re: Atari Lemans track roms - 09/08/22 10:22 PM
Ok, I think I've got it figured out how to do the crosshairs.


I scarfed the LIGHTGUN input ports from opwolf,

Code
	PORT_START("LGX")  /* P1X (span allows you to shoot enemies behind status bar) */
	PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)

	PORT_START("LGY")  /* P1Y (span allows you to be slightly offscreen) */
	PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)

and they only give 255 resolution, 0 to 0xff depending on the position of the crosshairs.

You can "expand" the resolution to 16 bit by doing:

PORT_BIT( 0xffff, 0x8000, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)


So just testing it out, I can see the x and y crosshair values change from 0 to 0xff.

We'll track the vsync and hsync:

Code
	NETLIST_ANALOG_OUTPUT(config, "maincpu:vsync", 0).set_params("VSYNC", FUNC(outlaw_state::update_vsync));
	NETLIST_ANALOG_OUTPUT(config, "maincpu:hsync", 0).set_params("HSYNC", FUNC(outlaw_state::update_hsync));

Code
NETDEV_ANALOG_CALLBACK_MEMBER(update_vsync)
{ 
	if (data < 1.0) 
	{ 
		m_vsync_elapsed = time.as_double() - m_last_vsync_time;
		m_last_vsync_time = time.as_double();  
		printf("VSYNC TIME = %f  ELAPSED=%.11f \n", m_last_vsync_time, m_vsync_elapsed);
		if (time.as_double() > 0.1) printf("NUMBER OF LINES = %.9f, %.9f, %.9f\n", m_vsync_elapsed, m_hsync_elapsed, m_vsync_elapsed / m_hsync_elapsed);
		printf("IOPORT=(%x,%x)\n", ioport("LGX")->read(), ioport("LGY")->read());
		m_linecount = 0;
	} 
}

NETDEV_ANALOG_CALLBACK_MEMBER(update_hsync)
{ 
	if (data < 1.0) 
	{ 
		m_linecount++;
		m_hsync_elapsed = time.as_double() - m_last_hsync_time;
		m_last_hsync_time = time.as_double();  
		printf("HSYNC LINECOUNTER=%d DATA=%f TIME = %f  ELAPSED=%.11f   CLOCKS=%f \n",m_linecount, data, m_last_hsync_time, m_hsync_elapsed, m_hsync_elapsed/(1.0/14.318e6));
	} 
}

One thing that's kind of odd is that the horizontal clocks alternate between 908 and 907. Strange, but it shouldn't be a problem.

Code
HSYNC LINECOUNTER=259 DATA=0.100000 TIME = 2.109106  ELAPSED=0.00006341668   CLOCKS=908.000000 
HSYNC LINECOUNTER=260 DATA=0.100000 TIME = 2.109170  ELAPSED=0.00006334684   CLOCKS=907.000000 
HSYNC LINECOUNTER=261 DATA=0.100000 TIME = 2.109233  ELAPSED=0.00006341668   CLOCKS=908.000000 
HSYNC LINECOUNTER=262 DATA=0.100000 TIME = 2.109296  ELAPSED=0.00006334684   CLOCKS=907.000000 
VSYNC TIME = 2.109353  ELAPSED=0.01660518229 
NUMBER OF LINES = 0.016605182, 0.000063347, 262.131201763
IOPORT=(83ff,2300)
HSYNC LINECOUNTER=1 DATA=0.100000 TIME = 2.109360  ELAPSED=0.00006341668   CLOCKS=908.000000 

So it's pretty easy to get the crosshair position and translate it to a x and y coordinate.


Then I'll set up a timer to do a m_guninput->write(gunvalue); to set the gun value at the correct time when the gun is sweeping at the appropriate x and y.



Code
	required_device<netlist_mame_analog_input_device> m_guninput;
	double m_last_vsync_time = 0.0;
	double m_last_hsync_time = 0.0;
	double m_vsync_elapsed = 0.0;
	double m_hsync_elapsed = 0.0;
	int m_linecount = 0;

        emu_timer *m_gun_timer = nullptr;



Setting up the netlist analog input device was kinda tricky.

make an input device:

required_device<netlist_mame_analog_input_device> m_guninput;

Code
	outlaw_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_video(*this, "fixfreq")
		, m_guninput(*this, "maincpu:guninput")  // input device with tag
	{
	}


void outlaw_state::outlaw(machine_config &config)
{
	NETLIST_CPU(config, m_maincpu, OUTLAW_VIDCLOCK).set_source(netlist_outlaw);
	NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0", 0).set_params("VIDEO_OUT", "fixfreq", FUNC(fixedfreq_device::update_composite_monochrome));
	NETLIST_ANALOG_INPUT(config, m_guninput, "GUNINPUT.IN");  // input device writing to the .IN
//	NETLIST_ANALOG_INPUT(config, "maincpu:guninput",  "GUNINPUT.IN");  // input device writing to the .IN  (either one should work)


then in the nl_outlaw.cpp file:
Code
	ANALOG_INPUT(GUNINPUT, 0)


and testing it out by writing values to it and reading those values with a NLAO (netlist analog output) to see if it indeed works.

Code
DEBUGNLAO(guninputread, GUNINPUT)    // note I called it guninputread so it wouldn't conflict with the maincpu:guninput tag



If I put this code in to set the gun input depending on the position of the light gun x coordinate (just as a test to see if I'm actually changing the input):

m_guninput->write(5.0 * ioport("LGX")->read() / 65536);

Code
VSYNC TIME = 0.548470  ELAPSED=0.01660511245 
NUMBER OF LINES = 0.016605112, 0.000063417, 261.841409691
IOPORT=(5140,8bff)
UPDATE guninputread: 0.548470  guninputread= 1.586914    delta=0.016605  delta2=0.033210


=================


One thing I found is that you can only have a single "outlet" hooked up to a NLAO. So the VIDEO_OUT gets connected to fixfreq, so how to "snoop" on it?

NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0", 0).set_params("VIDEO_OUT", "fixfreq", FUNC(fixedfreq_device::update_composite_monochrome));

My idea was to hook up a resistor with zero resistance using NET_C() to the VIDEO_OUT and then do a NLAO on the second terminal of the zero resistor.
Posted By: Golden Child Re: Atari Lemans track roms - 09/11/22 01:58 AM
After much fiddling around, I was able to get the crosshairs and explosion to sometimes track together. I wanted to use the video device's time_until_pos but couldn't get it work quite right.

m_gun_timer->adjust(m_video->screen().time_until_pos(m_gunx, m_guny), 1);

I decided to set a timer when the hsync would get updated.

Code
NETDEV_ANALOG_CALLBACK_MEMBER(update_hsync)
{ 
	if (data < 1.0) 
	{ 
		m_linecount++;
		m_hsync_elapsed = time.as_double() - m_last_hsync_time;
		m_last_hsync_time = time.as_double();  
	//	printf("HSYNC LINECOUNTER=%d DATA=%f TIME = %f  ELAPSED=%.11f   CLOCKS=%f \n",m_linecount, data, m_last_hsync_time, m_hsync_elapsed, m_hsync_elapsed/(1.0/14.318e6));
		if (ioport("IN0")->read() & 0x10)
		{
			if (m_linecount >= m_guny && m_linecount <= m_guny + 5) 
				m_gun_timer->adjust(attotime::from_double(m_hsync_elapsed * (m_gunx / 800.0)), 0);
			else m_guninput->write(5.0);
		}
		else m_guninput->write(5.0);
	} 
}

NETDEV_ANALOG_CALLBACK_MEMBER(update_vsync)
{ 
	if (data < 1.0) 
	{ 
		m_vsync_elapsed = time.as_double() - m_last_vsync_time;
		m_last_vsync_time = time.as_double();  
		printf("VSYNC TIME = %f  ELAPSED=%.11f \n", m_last_vsync_time, m_vsync_elapsed);
		if (time.as_double() > 0.1) printf("NUMBER OF LINES = %.9f, %.9f, %.9f\n", m_vsync_elapsed, m_hsync_elapsed, m_vsync_elapsed / m_hsync_elapsed);
		printf("IOPORT=(%x,%x)\n", ioport("LGX")->read(), ioport("LGY")->read());
		m_gunx = ioport("LGX")->read() / 65535.0 * 908;
		m_guny = ioport("LGY")->read() / 65535.0 * 262;
		m_linecount = 0;
	} 
}

virtual void machine_start() override 
{
	m_gun_timer = timer_alloc(FUNC(outlaw_state::update_gun_input), this);
};
	
TIMER_CALLBACK_MEMBER(update_gun_input)
{
	m_guninput->write((param) * 5.0); 
}

Here's a video of shooting the outlaw a couple of times, with a little bit of tweaking it should be able to make it track the crosshairs more closely (I see that I should probably have divided m_gunx by 908 instead of 800):

Posted By: Golden Child Re: Atari Lemans track roms - 09/11/22 06:29 AM
Putting in a horizontal adjustment and getting it calibrated:

Code
double fixrange(double from)
{
	double left = ioport("LEFTADJ")->read() / 100.0;
	if (left > 0.50) left = left - 1.0;  // greater than 50 treat it as less than zero
	double right = ioport("RIGHTADJ")->read() / 100.0;
	double fromrange = right - left;
	double to = (from - left) / fromrange;
	if (to > 1.0) to = 1.0;
	if (to < 0.0) to = 0.0;
	return to;
}

NETDEV_ANALOG_CALLBACK_MEMBER(update_hsync)
{ 
	if (data < 1.0) 
	{ 
		m_linecount++;
		m_hsync_elapsed = time.as_double() - m_last_hsync_time;
		m_last_hsync_time = time.as_double();  
	//	printf("HSYNC LINECOUNTER=%d DATA=%f TIME = %f  ELAPSED=%.11f   CLOCKS=%f \n",m_linecount, data, m_last_hsync_time, m_hsync_elapsed, m_hsync_elapsed/(1.0/14.318e6));
		if (ioport("IN0")->read() & 0x10)
		{
			if (m_linecount >= m_guny - ioport("TOPADJ")->read() && m_linecount <= m_guny + 5) 
				// m_guninput->write(5.0);
//				m_gun_timer->adjust(attotime::from_double(m_hsync_elapsed * (m_gunx / 908.0)), 0);
				m_gun_timer->adjust(attotime::from_double(m_hsync_elapsed * fixrange(m_gunx / 908.0)), 0);
			else m_guninput->write(5.0);
		}
		else m_guninput->write(5.0);
	} 
}

...
	PORT_START("LEFTADJ")
	PORT_ADJUSTER( 95, "Left Adjustment Crosshair" ) PORT_MINMAX(0, 100)  // greater than 50 treat it as negative

	PORT_START("RIGHTADJ")
	PORT_ADJUSTER( 109, "Right Adjustment Crosshair" ) PORT_MINMAX(0, 120)

	PORT_START("TOPADJ")
	PORT_ADJUSTER( 5, "Right Adjustment Crosshair" ) PORT_MINMAX(0, 120)






Doing the same for the vertical dimension too should make it very exact.
Posted By: Golden Child Re: Atari Lemans track roms - 09/11/22 03:31 PM
Okay, got it calibrated vertically as well as horizontally:

Code
double fixrange(double from, double left, double right)
{
	left = left / 100.0;
	if (left > 0.50) left = left - 1.0;
	right = right / 100.0;
	double fromrange = right - left;
	double to = (from - left) / fromrange;
	if (to > 1.0) to = 1.0;
	if (to < 0.0) to = 0.0;
	return to;
}

NETDEV_ANALOG_CALLBACK_MEMBER(update_hsync)
{ 
	if (data < 1.0) 
	{ 
		m_linecount++;
		m_hsync_elapsed = time.as_double() - m_last_hsync_time;
		m_last_hsync_time = time.as_double();  
		if (ioport("IN0")->read() & 0x10)
		{
			double guny = fixrange(m_guny / 262.0, ioport("TOPADJ")->read(), ioport("BOTTOMADJ")->read()) * 262;
			if (m_linecount >= guny  && m_linecount <= guny + 5)
				m_gun_timer->adjust(attotime::from_double
					(m_hsync_elapsed * 
						fixrange(m_gunx / 908.0, ioport("LEFTADJ")->read(), ioport("RIGHTADJ")->read())
					), 0);
			else m_guninput->write(5.0);
		}
		else m_guninput->write(5.0);
	} 
}

	PORT_START("LEFTADJ")
	PORT_ADJUSTER( 95, "Left Adjustment Crosshair" ) PORT_MINMAX(0, 100)  // greater than 50 treat it as negative

	PORT_START("RIGHTADJ")
	PORT_ADJUSTER( 109, "Right Adjustment Crosshair" ) PORT_MINMAX(0, 120)

	PORT_START("TOPADJ")
	PORT_ADJUSTER( 99, "Top Adjustment Crosshair" ) PORT_MINMAX(0, 120) // greater than 50 treat it as negative

	PORT_START("BOTTOMADJ")
	PORT_ADJUSTER( 104, "Bottom Adjustment Crosshair" ) PORT_MINMAX(0, 120)

Posted By: Golden Child Re: Atari Lemans track roms - 09/15/22 10:41 AM
One thing that's been perplexing me is why the number of clocks changes from line to line, and what I've found is that if you have a 7493 connected to another 7493, the second 7493 won't actually respond to a change in the first 7493's high bit output until the next clock cycle.

It led me to experiment with trying different cpu clocks, multiples of 14.318e6 being most visually appealing:

Code

/ PORT ADJUSTER 16 BIT MASK since default mask is 0xff, not big enough for a MINMAX of (1,10000)
#define PORT_ADJUSTER_FFFF(_default, _name) \
	configurer.field_alloc(IPT_ADJUSTER, (_default), 0xffff, (_name)); \
	configurer.field_set_min_max(0, 100);


	PORT_START("CPUSCALE")
	PORT_ADJUSTER_FFFF( 100, "CPU Scale Adjustment" ) PORT_MINMAX(1, 10000)  PORT_CHANGED_MEMBER(DEVICE_SELF, outlaw_state, set_clock, 0)




INPUT_CHANGED_MEMBER(set_clock) { 
	m_maincpu->set_unscaled_clock_int(ioport("CPUSCALE")->read() / 100.0 * 14.318e6);
	machine().popmessage("Clock Scale = %f    clock= %f",ioport("CPUSCALE")->read() / 100.0, m_maincpu->clock());
	}


Sometimes it seems like the higher the clock, the more visual artifacts.


Looks very pixelated at a .25 scale:

[Linked Image from i.imgur.com]

[Linked Image from i.imgur.com]

[Linked Image from i.imgur.com]


going slightly over the even multiple seems to cause "ghosting":

[Linked Image from i.imgur.com]



I could also use the -cheat parameter which enables the overclock slider and allows me to set an over/underclock up to 400% but I wanted to go higher than that, do PORT_MINMAX(1, 10000) for up to a 100x multiple.
© Forums