Rogue-like ascii based on Arduboy

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

@Pharap and all of person who posted, very thank you!

I got to learn a lot of precious opinions and information, and I really learned.

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 want to rewrite this program with struct — hero, item, monster, dungeon and so on.
And I will challenge GitHub!

2 Likes

When I was examining about arduino, I came across a @Mr.Blinky 's article by Arduboy made with breadboard.I assembled it and tried playing some games.And, as I opened the sample “Hello world.ino” and moved the characters “Hello world”, I wanted to make something game.The game I came up with was then “Rogue”.

Although “Rogue” is a small program, I thought it was impossible to fit all the programs to 32 kbytes.The binary of “Rogue” for windowsOS in my hand is also 152 kbytes! At first I thought about omitting rings and wands, but I felt like trying to do as much as I could.

My “Hello world” program grew bigger and bigger.Both the variables and the code became more and more messed up.Sorry to everyone who downloaded the source program.

I did not feel like completing it and I did not intend to complete it, so the file name was still “HelloWorldx.ino”.However, I think that it was good.I was able to meet the new world (everyone in this community).

There are many different points from the original “Rogue”.
-Poor message
-Items with different effects
-Invocation condition of special attack
-etc…etc…etc…
I want to play a complete original “Rogue clone” on Arduboy. Furthermore, I want to bring it closer to the original “Rogue”.I would be happy if you play and give me opinions.

3 Likes

It’s fine. Least you fit them in.

According to GunMan Tacco Truck (a popular iOS game), nothing is inedible.

You do? :crazy_face:
Would you mind sharing that bit?


Good luck on your next program!

1 Like

No, no!
I can not write windows app. It is “Rogue Clone II for Win32 Version 1.3.4” by HEPOPO.

I will make NetHack! :joy:

2 Likes

Great!
Then I’ll just wait to test your great work then.

If you explain what ii, i1, i2 … are,
I can show you how to use a struct instead.

At the moment I cannot use a struct,
because I don’t understand how ii, i1 etc are functioning.

There are special techniques and strategies for reducing the code size.

The first thing I did was to change how the strings are stored:

To understand strings.h, you need to understand arrays and pointers.

Before, you used 2D arrays.
Now I am using char arrays and arrays of const char * (pointers).
This uses less memory.

Hopefully these images will be understandable.
(The '0’s are actually '\0', the ASCII ‘null character’.)

2D array:
2DArray
(Too many '0’s - wasted space.)

Array of pointers:
Pointers
(No wasted space.)


The second thing I did ‘the FlashStringHelper trick’.
To understand that, you need to know about “function overloading”.

1 Like

This is a new release.
Now available on original Arduboy.

HelloWorld9red2.ino.hex.pdf (78.7 KB)

This version is:
[FIX] An unidentified scroll appears in the game.
[FIX] Wnen you read ? of anger, there are many kestrels.
[FIX] When you blind, you cannot read scroll.

@Pharap many thanks.
I take time to read English sentences.I also write English sentencestake time. I’m really sorry that the reply was delayed.

2 Likes

To @Pharap , many many thanks.

I’m sorry to have trouble. It is absolutely necessary for the game loading and saving function.

They are:

ii ID item
7~4 bit kind of the item(1=gold, 2=food, … 9=amulet)
3~0 bit variation(0=food, 1=mold…)

i1 amount of the item
In most case 1, stackable items are amount.
Stackables are 2=food, 3=weapon(variation>=4), 5=potion, 6=scroll

i2 bonus 1
3=weapon: extra dex.
4=armor : extra AC
7=ring : extra bonus(= of dex and damage)
8=wand : number of charge

i3 bonus 2(only weapon)
3=weapon: extra damage

i4 bit flag
7 bit: stackable
6 bit: cursed
5 bit: known(for weapon, armor, ring and wand)
4 bit: wielded(for weapon, armor and ring)
3 bit: coated(for armor)
2 bit: opened(for ? of scare)
1 bit: known2(not available now)
0 bit: not use

Wow! It is a wizard magic for me! But I want to do my best and understand.

1 Like

Thank you so much for this game. It really is really awesome. Finally someone released a rogue game like I like them.

Is it normal that even if I die when I start over I am still at the level I died at? And keep all the loot I have? Also is there an ending or it’s just random infinitely?

2 Likes

怒りの”?”ですか?

Kestrel? “長元坊”?

私も。私は遅い、日本語が上手じゃないですから。

To explain in Japanese would take a long time.

大丈夫さ。

ビット七は左とビットゼロは右ですか?
ビット七は右とビットゼロは左ですか?

(I don’t know how to say “or” in Japanese… 又は? “左又は右”?)

The code could look like this:

enum class ItemType : uint8_t
{
	None = 0x00,
	Gold = 0x01,
	Food = 0x02,
	Weapon = 0x03,
	\\ ...
	Amulet = 0x09,
};

enum class ItemId : uint8_t
{
	Gold = 0x10,
	Food = 0x20,
	Mold = 0x21,
	Mace = 0x30,
	Axe = 0x31,
	Sword = 0x32,
	Bow = 0x33,
	Dart = 0x34,
	\\ ...
};

ItemType getType(ItemId itemId)
{
	return static_cast<ItemType>((static_cast<uint8_t>(itemId) >> 4) 0x0F);
}

enum class ItemAttributes : uint8_t
{
	None,
	Stackable = (1 << 0),
	Cursed = (1 << 1),
	Known =  (1 << 2),
	Wielded = (1 << 3),
	Coated = (1 << 4),
	Opened = (1 << 5),
	Known2 = (1 << 6),
	Reserved = (1 << 7),
};

struct Item
{
	ItemId item;
	uint8_t amount;
	uint8_t stat;
	uint8_t damage;
	ItemAttributes attributes;
};

Item inventory[10];

enum class: https://ja.cppreference.com/w/cpp/language/enum
static_cast: https://ja.cppreference.com/w/cpp/language/static_cast
0x00/0x31 etc: https://www.mathsisfun.com/binary-decimal-hexadecimal.html

はい!私は魔道士だ!ゼハハハハ!

(それは冗談です。 私は髑髏! 私は人間。)

I want to explain, but explaining in Japanese is difficult.
I do not know the correct words.
(E.g. ‘function’, ‘call a function’, ‘object’, ‘class’)

Maybe you will understand this code?:

const char text1[] PROGMEM = "hello world";

// In RAM
const char text2[] = "goodbye world";

void thing1()
{
	// 嘘. (Incorrect)
	// Calls Print::print(const char str[])
	// Tries to read RAM, not PROGMEM.
	aruboy.print(text1);
	
	// 正解. (Correct)
	// Calls Print::print(const char str[])
	// Reads RAM.
	aruboy.print(text2);
}

void thing2()
{
	// 正解. (Correct)
	// Calls Print::print(const __FlashStringHelper *)
	// Reads PROGMEM.
	aruboy.print(reinterpret_cast<const __FlashStringHelper *>(text1));
	
	// 嘘. (Incorrect)
	// Calls Print::print(const __FlashStringHelper *)
	// Tries to read PROGMEM, not RAM.
	aruboy.print(reinterpret_cast<const __FlashStringHelper *>(text2));
}

size_t Print::print(const __FlashStringHelper *ifsh):


(while(1) should be while(true).)

See pgm_read_byte? It reads from ‘progmem’.

Many Thank you, @Vampirics !

I thought that no one has played this game. Looking at your message, I am very pleased to know that at least one person is playing this game. I’m really thankful to you.

I’d like to add save and load functions to this game. But I have not done it yet. I programmed to be able to continue the game until that function is attached. It is normal behavior.
Amulet is falling deeper than the 26th floor of this dungeon. When you pick up that amulet, the descending staircase changes to an upstairs stairway. If you return to the ground with that amulet you will be Winner.

1 Like