Rogue-like ascii based on Arduboy

Rogue.hex (78.6 KB)

I am sorry for my poor English.
I wrote my first Arduboy code, and I become “basic user” in this community.
Now upload my .hex file. It has MANY bugs, maybe. I want to fix them, but I have no memory more…

Untitled1
(Very poor) title

Untitled2
main window

Untitled3
Inventry window

Untitled4
Status window

Dpad key: move, attack and select menu
A button: rest, search, show status and accept
B button: inventry and deny
red LED: low hunger level, hit point

It runs on Cathy3K bootloader.
Thanks to the community, now it is executable on caterina bootloader!
The latest release is version 1.5.6.

Source:

Rogue156b.zip.pdf (94.3 KB)

13 Likes

If you post the source code someone could probably help you with the memory usage (ram or PROGMEM)

2 Likes

Hrm, I’m not sure how many people have the Cathy3K bootloader on their Arduboys.

@Freezingsnail is right here, if you post the code we might be able to find some PROGMEM savings.
We have some very clever people here.

You don’t have to publish the source code if you don’t want to, but it is highly encouraged.
Sharing code helps everyone to learn.

Most people use a GitHub or GitLab account to host code.
(They can seem scary at first, because they do more than just host files, but they are very useful.)

2 Likes

Thank you for your interest.

Hrm, I’m not sure how many people have the Cathy3K bootloader on their Arduboys.

I think so, too.
I have learned a lot from this community.If I lead to the revitalization of this community, I would like to return my gratitude.

But I am an old programmer.I can understand BASIC, but I do not understand C ++ at all.So, I think it is a very difficult to read, difficult to understand code.So, I think it is a very difficult to read, difficult to understand code.

rogue.zip.pdf (168.1 KB)

It is embarrassing with dirty code but it will be released.
thank you, @Freezingsnail and @Pharap.

1 Like

I’m sorry. I wrote the same thing twice.

If I change the font to uppercase letters, what will it be?
I am thinking about such a thing now.

I love the title screen it says what it is and does what it has to and nothing else.

1 Like

Maybe change the text size from 1 to 2?
you can fit textsize(3) “rogue” onto the screen, but I don’t know.
Firstly, let’s reduce the size of the thing.

Thank you, @Keyboard_Camper and @CDR_Xavier.

I am trying to reduce size of my .hex file for Caterina bootloader, because of for original Arduboy platform.

I must reduce 660 byte.
I will do my best!

1 Like

There’s plenty of time to learn. Anything you don’t understand, just ask.

You might find some of the resources in my Resource Collection helpful:

I especially like this tutorial:
https://www.learncpp.com/

I guarantee I have seen worse code.
(And I have possibly written worse code.)

By the way, ‘code’ is ‘uncountable’ like ‘sand’ and ‘water’.
It’s never ‘a code’, it’s just ‘code’.
(Like how in Japanese you don’t have an ‘a’, every noun is ‘uncountable’.)

この ‘HelloWorld2’, ‘HelloWorld3’ … ‘HelloWorld9’…
それはバージョンでしょう?

GitHubGitLabは"バージョン・コントロール"があります。

私はGitHubがすき。)

これは”エディット・ツール”です:

(この鉛筆のアイコン。赤ボックス。)

Keywords must be lowercase.
Identifiers (e.g. variables, types) can be uppercase or lowercase.

でも、C++は"ケース・センシティヴ"(“case sensitive”)。
I.e. random is not the same as Random.


Some advice:

Tip #1:
Please don’t use ‘contractions’ in your code. Contractions make code hard to read.
(I.e. Use damage, don’t use dmg. Use Monster, don’t use Monst.)

Tip #2:
Please use uint8_t instead of byte.
byte is Arduino only. uint8_t is standard (i.e. it works on desktop too).

Tip #3:
Use descriptive names. ii does not explain anything.

Golden Rule:
Code is not written for the computer. (The computer is happy with 1s and 0s.)
Code is written for humans to read and understand.


I will look for some ways to reduce the code size,
but I am having problems understanding what some of the variables mean.

By looking at your code, I can understand what you don’t know yet.

It seems you don’t know about bool yet.
bool が論理のタイプです。
bool can be true (正) or false (偽).
You should use bool instead of using a byte with 1 and 0.

E.g.

byte freeSlot() {
  bool done = false;
  byte count = 0;
  while (!done) {
    if ( id[count] == 0 ) {
      done = true;
    } else {
      count++;
      if (count == TMAX) {
        done = true;
      }
    }
  }
  return count;
}

The ! means ‘not’ (ざる/じゃない).
I.e. !true == false and !false == true.

But in this case, you can do something better:

byte freeSlot()
{
	for(byte index = 0; index < TMAX; ++index)
	{
		if (id[index] == 0)
		{
			return index;
		}
	}
	return TMAX;
}

(Uses 4 less bytes of progmem. Simpler = smaller.)


Another thing you do not yet know about is struct.

I see you have an array of items (ii, i1, i2…).
I don’t know what the different arrays mean, but I understand what you are doing.
An Item struct would be useful for this.

I shall demonstrate a struct:

struct Point
{
	int x;
	int y;
};

void demo()
{
	// point.x = 0; point.y = 0;
	Point point { 0, 0 };
	
	point.x = 5;
	// point.x = 5; point.y = 0;
	
	point.y = 6;
	// point.x = 5; point.y = 6;
	
	// point2.x = 1; point2.y = 2;
	// point.x = 5; point.y = 6;
	Point point2 { 1, 2 };
	
	point = point2;
	// point2.x = 1; point2.y = 2;
	// point.x = 1; point.y = 2;
}
1 Like

That’s not a lot. I’d take a good look if I had the time for it.
@Pharap does “F-marcroing” the string work for this case?

Unfortunately @BlueMax has already used the F macro.


I’ve been working on reducing it…

Before:

Sketch uses 30236 bytes (105%) of program storage space. Maximum is 28672 bytes.
Global variables use 2330 bytes (91%) of dynamic memory, leaving 230 bytes for local variables. Maximum is 2560 bytes.

Now:

Sketch uses 29812 bytes (103%) of program storage space. Maximum is 28672 bytes.
Global variables use 2332 bytes (91%) of dynamic memory, leaving 228 bytes for local variables. Maximum is 2560 bytes.

That’s 424 bytes down, 1140 bytes to go.

I’m curious to see what was he typing …
Unfortunately, my laptop’s multiple parts decide to stop working together. Need some fix.


;-;

Are there unused ascii characters in the font that can be removed?

Also if building specifically for cathy3k as the target you can also ditch USB for more space, the bootloader still allows uploading.
It’s more a pain to ditch it for standard users.

He needs 660, so only 236 to go?

29812 - 28672 = 1140

I was aiming for getting it in under 100%

30236 - 660 would be 29576, in which case I’m currently 36 bytes away from that,
but I haven’t checked that my changes haven’t broken anything yet because I can’t.
(Unless ProjectABE accepts oversized sketches without a problem?)

I can’t guarantee that it works, but I’ve certainly shrunk it.

Sketch uses 29528 bytes (102%) of program storage space. Maximum is 28672 bytes.
Global variables use 2304 bytes (90%) of dynamic memory, leaving 256 bytes for local variables. Maximum is 2560 bytes.

That’s 708 bytes of progmem saved and 26 bytes of RAM saved.

I’m hosting my modified version on GitHub for now because it’s easiest.

2 Likes

@Pharap if you install @Mr.Blinky’s board package you can compile for Cathy3k and it should run under ProjectABE (least it did last I tried) also great for testing extra features during development that will normally not fit.

why is my compile size 29920 some?

size down to 29894;
down to 29904!

I don’t know about the compile size. My complier must be toying me.
Go ahead and try that.
@Pharap I had created a pull request for the changes.
In addition to RAM saving, the formatting was also fixed. Mostly.

Many thanks for all of this community.
Now, this .hex runs on Caterina bootloader.

.hex is here.

HelloWorld9red.ino.hex.pdf (78.3 KB)

Anyway .hex file only.

1 Like

Sorry.

red(uce) version is:
-LED notification is omitted.
-Something to eat (food and mold) are yummy always.

2 Likes