Rogue-like ascii based on Arduboy


#201

Thank you for your valuable information. I tried that.

When “Sprites::…”
Sketch uses 28150 bytes (98%) of program storage space. Maximum is 28672 bytes.

When “SpritesB::…”
Sketch uses 28242 bytes (98%) of program storage space. Maximum is 28672 bytes.

Am I something wrong?


(Simon) #202

There are two libraries that mimic the functionality of each other. Are you using any other Sprites functionality directly or through other classes? Does your code do Arduboy.draw…() or any other draw…() command? If so, swap it to SpritesB as well.


#203

Thank you for your quick reply, @filmote !

I will investigate!


(Pharap) #204

Whereabouts?

I just ctrl+f-ed it to check the repo I made to demonstrate the changes and I couldn’t find that.

‘Huge long explanations’ are my speciality.


The only reason __FlashStringHelper is needed in the first place is because AVR chips have different machine code instructions for reading from progmem and reading from RAM.

On ARM Cortex chips, both the RAM and the flash ‘ROM’ use the same address space so none of this additional magic is needed.


All you really need are LCDCommandMode, LCDDataMode and SPItransfer, which have been public for as long as I can remember.

Admitedly having an actual moveHardwareCursor function would be more convinient, but it’s hardly a common operation.

No, I was waiting for @BlueMax to decide whether he is comfortable with the changes or not.
Often people do not like incorporating code unless they fully understand it.

He has since commited the changes:

Personally I’ve never bothered to learn the commands for git.
I gave the command line tool a go and found it too cumbersome and convoluted,
so I just stick to using GitHub’s UI.

You still need to understand commits and branching at some point though, which can be very difficult.

I still remember a time when I didn’t know what file extensions were, didn’t know the difference between a gigabyte and a megabyte and hadn’t written a line of code in my life.

That’s one of the reasons I spend so much time helping people by explaining things - to ensure I never forget how difficult programming truly is or how hard it is to become good at it.


(Pharap) #205

いえいえ。

紫水晶がすきです。(あれは紫色ですから。)

Maybe you only changed one of the two lines?

I made a PR for this:

(Co-authored by @filmote, because it was his idea.)


Also, about the “red6” commit, “Apply @Pharap’s FlashStringHelper” would have been a much better title than “red6”.
It’s okay though, good commit titles are difficult to write.

The important thing is you are using GitHub. That’s good.


#206

Thank you, @Pharap.

I tried it, but the result was as above. I used “arduboy.fillRect” for inverting characters, so I made the following corrections.

src/fonts/font5x7.cpp

add:

const uint8_t PROGMEM back_ground[] = {
6, 8,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};

rewrite:

  if (idx > -1) {
    if (_textColor == WHITE) {
      Sprites::drawOverwrite(x, y, font_images, idx);
    }
    else {
      Sprites::drawOverwrite(x, y, back_ground, 0);
      Sprites::drawErase(x, y, font_images, idx);
    }
  }

And I invalidated six “arduboy.fillRect”.
result:

Sketch uses 27948 bytes (97%) of program storage space. Maximum is 28672 bytes.

So rewrite the three “sprites ::” to “spritesB ::”
result:

Sketch uses 28050 bytes (97%) of program storage space. Maximum is 28672 bytes.

Do I have to rewrite some other part?


(Pharap) #207

なるほど。

Spritesの関数:

  • Sprites::drawExternalMask
  • Sprites::drawPlusMask
  • Sprites::drawOverwrite
  • Sprites::drawErase
  • Sprites::drawSelfMasked

All of those call Sprites::draw,
and Sprites::draw calls Sprites::drawBitmap.

このコードで:

  if (idx > -1) {
    if (_textColor == WHITE) {
      Sprites::drawOverwrite(x, y, font_images, idx);
    }
    else {
      Sprites::drawOverwrite(x, y, back_ground, 0);
      Sprites::drawErase(x, y, font_images, idx);
    }
  }

Sprites::drawBitmap is called 3 times.

I think that after 3 calls the compiler stops inlining Sprites::drawBitmap because it’s a very big function.

2関数呼出し→Sprites::drawBitmapインライン展開です。
3関数呼出し→Sprites::drawBitmapインライン展開じゃないです。

I think that is why the size is increasing.


Hrm… I have one idea… arduboy.invert(true).

arduboy.invert(true)は画面の色を転倒する。
白→黒、黒→白。


(Josh Goebel) #208

Yes, it’s very nice. :slight_smile: Plus (at least on ARM M0+) you can run code from RAM also, though no one seems to focus on that.

Admitedly having an actual moveHardwareCursor function would be more convinient, but it’s hardly a common operation.

Right, you just have to look up the codes from the PDF. And core.h does already have push 8 pixels although that’s really just an SPItransfer.

He has since commited the changes:

Awesome.

Personally I’ve never bothered to learn the commands for git.

I started with the command line and still used it often. The super nice thing about GitHub is the PR review/comment/etc/merge process. But if I’m working on a project solo I might never even use the GItHub UI ever.

You still need to understand commits and branching at some point though, which can be very difficult.

I was doing that stuff with Perforce like 20 years ago, so I brought that with me to Git.

That’s one of the reasons I spend so much time helping people by explaining things - to ensure I never forget how difficult programming truly is or how hard it is to become good at it.

You should consider mentoring on Exercism.io, I’ve really been loving the time I’ve been spending there.


#209

Thank you, @Pharap. I will investigate.

I noticed that the trap of “Big room” is behaving strange behavior… I’m sorry. I will fix it soon.


(Pharap) #210

If I’m working on something and I’m not pushing it to GitHub then I won’t even bother with git because commiting is too much work for just my own benefit.

But GitHub allows private repos for free now, so I can use it for things I’m not ready to publish if I want.

I wouldn’t really have the time to spare. Too many projects on the go.

(They probably want professionals anyway, and I’m not a professional, I’m just a hobbyist.)


(Josh Goebel) #211

Yeah that helps, but I’ve had client projects forever so I’ve always had a paid account and private repos available.

They probably want professionals anyway, and I’m not a professional, I’m just a hobbyist.

I don’t think that’s true - if you ever find time. I think the important thing is knowing a language well enough to tutor it, not whether you do it for work or a hobby.


#212

I will tell you the truth.
While programming my “Rogue”, I thought that “save function” could not be realized. It continued until the last compilation was over…

I will release a new “Rogue” that realized “permanent death”! Finally, “save function” has been realized. The new version is 1.5.

Rogue15.hex.pdf (78.7 KB)

CAUTION
This version uses “remove USB stack” technique. When you upload a new game, you need to hold down the DOWN button while ARDUBOY is starting up.

This version is:

  • [FIX] “Big room’s trap” problem
  • [SYS] A hero no longer survives.
  • [SYS] Implementation of “save function” *1

*1 An inquiry will be made when descending the stairs.(or climbing the stairs)
landing
A_BUTTON) Keep on traveling
B_BUTTON) Save and Exit
Save data will be invalid when turning off the power or resetting in dungeon.


(Simon) #213

Its been fun watching this game evolve with help from the community. Good work!


#214

Thank you, @filmote !

You always gave me good, easy-to-follow advice. I am very grateful to you! :grinning:


#215

I like how this goes!
:heart_eyes:
@vampirics Good idea of swapping out the letters for sprites!
Perhaps I can make a letter-based Sokoban someday …


(Stephane C) #216

I didn’t try the new version yet, but what’s the point of saving if when you turn off the Arduboy you lose the save? Unless it’s after loading back the game that the save is lost?

Can you put the latest source in your repo? Right now I think it’s v 1.4 in it.


(Stephane C) #217

Was a good idea but I am not doing it properly. I rushed it because I really don’t have much free time. But yeah it kinda works.

And the letters/symbols are already sprites anyway so I basically just changed how each letter sprites are looking. Nothing hard there. Hardest part was creating sprites that small


(Pharap) #218

@BlueMax, GitHubの授業:時間旅行

選択A:

  1. commits(変更履歴)

  1. 十六進法整数(これはコミットのハッシュです)

  1. Browse Files

  1. これはコミット履歴です。

選択B:

  1. commits(変更履歴)

  1. <>

  1. これはコミット履歴です。


これはバージョン管理システムの パワーです。

コード履歴は行方不明じゃないです。


Does that make sense?


(Simon) #219

Its all Greek to me!


(Pharap) #220

ギリシャ語じゃないです。

Anyway, you’re supposed to say:
「はい、なるほど。フェアラプは一番 プログラマーです」
:P

(In case whatever translator you try to use doesn’t recognise it, “フェアラプ” is “Pharap”.)