New demo uploaded: Pirate Kingdoms

All aspects of programming on the Commander X16.
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »




Pirate Kingdoms




View File






A demonstration of the use of C, sprites, and banks to create a tiled map.

Everything is quite primitive right now.  The scrolling is terrible.

The map is 256 x 256 and stored in banks 10-17 (it's 64k).  My plan is of course to make it larger.

Use the cursor keys to move about the map. 

 






  • Submitter



    rje




  • Submitted


    02/16/21




  • Category







 
kelli217
Posts: 542
Joined: Sun Jul 05, 2020 11:27 pm

New demo uploaded: Pirate Kingdoms

Post by kelli217 »


Cool! I didn't pay attention to your warning and went to the edge, and caused a bad subscript error. Whoops! ?

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »


The map drawing routine is my target.  If I put it in assembly then ... well it'll be superfast.


rem dx,dy is the top left corner of the map view
bb=0 :rem this prevents us from POKEing the bank every loop
for r = 0 to \rows-1
   y = dy + r
   y3 = int(y/32) :rem each RAM bank has 32 rows
   ba = 10 + y3   :rem there's our bank number
   if bb <> ba then bb=ba :poke $9f61,ba
   yy = 32 * (y/32-y3) :rem y mod 32

   for c = 0 to \cols-1
      x = dx + c

      la = peek($a000+yy*256+x) :rem tile value
      bk=l1(la) :rem MSB for sprite block
      ls=l2(la)  :rem LSB for sprite block
      s0=s0(r,c) :rem cached sprite address offset
      vpoke $f, s0+0, %00000000 + ls
      vpoke $f, s0+1, %10000000 + bk
   next c
next r
return


 

First, the code is a mess.  It's very busy, and seems to be inefficient for simply updating a map.

The data required to update any one tile is:

1. The correct bank and offset of the data.

2. The MSB value to poke.

3. The LSB value to poke.

4. The sprite's register offset.

 

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »



19 minutes ago, kelli217 said:




Cool! I didn't pay attention to your warning and went to the edge, and caused a bad subscript error. Whoops! ?



Off by one I suspect.  Thanks for finding it! 

Ah, that's a "bug" with my map, not the code.  The first two bytes used to store the map dimensions, causing your error.  I'll upload a new map.

 

kelli217
Posts: 542
Joined: Sun Jul 05, 2020 11:27 pm

New demo uploaded: Pirate Kingdoms

Post by kelli217 »


Yes, it works much better now. Stops and won't let me go beyond the bounds of the map.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »


Updated with settlements... sort of.

Buggy settlements.  I'm still working out how I want to do the sprite offsets there.  I figure if I can do half-height offsets, I can get twice the number of unique settlements.

 

User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

New demo uploaded: Pirate Kingdoms

Post by desertfish »


Pretty cool looking for a basic program!

The long initialization phase, is the program creating tiles on the fly or something?  Instead of loading bitmaps?

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »



On 2/17/2021 at 7:52 PM, desertfish said:




The long initialization phase, is the program creating tiles on the fly or something?  Instead of loading bitmaps?



Right, it loads the tiles into banked RAM... and then POKEs them into VERA.

I *think* I can load directly into VERA -- right? -- so I should be doing that!

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »


Here's things I want to do:

Migrate the code to C (because I know C)

Then...


  •  Improve the map (because... ugh)


  •  "Exit" the ship for land travel.


  •  "Board" ships for sea travel.


  •  Interactions with settlements.


  •  Interactions between settlements.


  •  New settlements.


Then I can start thinking about events that bring a little Dwarf Fortress feel to things.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New demo uploaded: Pirate Kingdoms

Post by rje »


Now that Core War is 1.0.0, I've started thinking about Pirate Kingdoms of the Rhylanor Coast.

In C, of course.

 

I. A PRETTY MAP

First, I need a pretty map.  The current map is ugly.  So I need rounded coastlines.  OK.

 

II. AN ECOLOGY


  • Settlements.  Depending on the type of land and size of settlement, they may grow, have Food (smaller settlements), Gear (larger settlements), and Ships (on the coastline).


  • Settlements interact with local flora, fauna, and other Settlements. Their size and gear rating determine the Settlements' radius of influence.  Thus Cities with excess Gear have the largest influence and can be very powerful.


  • Fortresses. A special kind of Settlement geared for defense.


  • Gear is an economic multiplier.  It stretches out your Food supply.  It makes you more effective in battle.  Gear builds and maintains Civilizations.  A prolonged loss of Gear production causes Settlements to fail and Civilizations to fall.


  • An established City may revolt and break off of a Civilization if there are prolonged problems.


III. PLAYER ACTIONS

Your Group can:


  • barter with Settlements for manpower, food, gear, ships -- if the settlements don't have a bad opinion of you.


  • or attempt to plunder them.


  • establish Settlements with an initial investment of manpower, food, gear, and ships.


  • be a "Primitive Wandering Bandit team", subsisting on trade and plunder.


  • be a "Leif Ericsson" band, arriving in ships to settle in an unknown land.


 

Post Reply