6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 27, 2024 4:25 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Apr 23, 2021 5:14 am 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 106
Location: Long Island, NY
Inspired by the other threads on using WDC's compiler, I started writing a Tetris implementation for my system in C.
It has modern "SRS" rotations, holds, and hard drops along with two-player versus mode.

The drawing code relies on my custom blitter circuit, but I've separated out the game logic from the drawing logic so that someone who wanted to fork it for another platform hopefully wouldn't have too much trouble. It could still stand some optimization, but runs decently well on both the emulator and the physical prototype.

Tetris repo:
https://github.com/clydeshaffer/GameTankTetris

GameTank emulator:
https://github.com/clydeshaffer/GameTankEmulator

Other notes...

In the process of getting the code generated by WDC02CC to work, I ended up adding a bunch more W65C02S opcodes to my fork of Gianluca Ghettini's emulation library. In particular, a target system will need to support the "zero page indirect" addressing mode to run binaries from this compiler.

The makefile should work on both Windows and Linux. Though I did have to modify zpage.inc and wdc02cc.cfg in the WDCTools dir to remove the "134" clauses. On Windows I run the makefile in git bash, which is why dd is an available command.

Ideally I should link to zlib6502 as a submodule and trigger its build in the makefile, but for now I'm a bit lazy and grabbed the binary I compiled a while ago and use for multiple projects. It's in the lib folder and labeled with its expected memory locations in the filename. Fortunately it turned out to not be overly difficult to "manually" link it. The file assets.asm defines a section with an absolute offset and imports the binary, as well as reserving the RAM locations it needs. This is enough to convince WDCLN to put it in the right place.

Later I'm planning to try building the C code with other emulators, and find out where the WDC02CC output rates against the likes of vbcc and cc65. For reference, here's the output of the linker as of the latest commit:
Code:
Section: ORG:    ROM ORG:  SIZE:
PAGE0    000020  ------       D4H (   212)
CODE     008000  008000     285AH ( 10330)
KDATA    00A85A  00A85A      AC9H (  2761)
DATA     000500  00B323      13EH (   318)
UDATA    00063E  ------      22BH (   555)
inflated 000200  000200      2FDH (   765)
inflate  00E000  00E000      1FCH (   508)
startup  00FE00  00FE00      164H (   356)
vectors  00FFFA  00FFFA        6H (     6)
Total                       3DC3H ( 15811)



Attachments:
Screenshot from 2021-04-22 22-27-57.png
Screenshot from 2021-04-22 22-27-57.png [ 9.98 KiB | Viewed 625 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 23, 2021 8:36 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1467
Location: Scotland
Thanks for this - I'm somewhat overly occupied with some home renovations following moving house, but when I have some time I'll definitely have a look at it.

My Ruby system handles sprites on the "smart" terminal, so they may well be faster to draw, etc. even though it's going over a serial line.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 23, 2021 11:49 am 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Thanks.

Agumander wrote:
Later I'm planning to try building the C code with other emulators, and find out where the WDC02CC output rates against the likes of vbcc and cc65.


This will be very useful indeed.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 23, 2021 1:19 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
I'll try to port the Robot Game I made for my 6502 language comparison when I get time. I already have the source for cc65 so hopefully it won't take long.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


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

Search for:
Jump to: