News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Capitals of Europe

Started by jj2007, September 25, 2020, 01:51:46 AM

Previous topic - Next topic

jj2007

New version attached above in the first post. It will grab the maps directly from the web:

GuiParas equ "Capitals of Europe", xr20, w1200, h600, m5, bLiteGrey, icon Globe ; right-align, width 1200px, margin 5px, grey background
; not needed: GuiMenu equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste ; creates a menu -> Event Menu
include \masm32\MasmBasic\Res\MbGui.asm ; OPT_Close Capitals of Europe ; close the window before building
.if !Exist("Capitals\euro5.dmi")
MsgBox 0, "Maps are missing. Ok to download them?", "Hi", MB_OKCANCEL
If_ eax==IDCANCEL Then Exit
UnzipInit "http://www.jj2007.eu/images/Capitals.zip" ; get the maps
For_ ecx=0 To edx-1 ; #files returned in edx
UnzipFile(ecx, Cat$(CurDir$()+"Capitals\")) ; extract to a new folder
Next
.endif
GuiControl TheImage, "canvas", w600 ; use the 3-letter shortcuts gcbutton, gcedit, gclistbox, gcrichedit, gcstatic to insert other controls, e.g typing gcb<space>
GuiControl TheMap, "canvas", x600, w400
GuiControl Sbar, "statusbar", wCat$(wDate$+", "+wTime$+" - click into the map")
ArrayLoadMap 0, "Capitals\euro5" ; *.dmi and *.map
MapColours(0, "gahebcdbfghgfgcdefghegaechfgaggfcdgfgceghaefabcdheg") ; set colours to map #0 (a=red, i=dark green, l=blue)
Recall "Capitals\Capitals.ini", pics$() ; info on jpg files

Event Message
  .if uMsg_==WM_MAPCLICKED && MapRegion>=0
SetWin$ hSbar=MapRegion$
invoke InvalidateRect, hTheImage, 0, 0 ; force image redraw
  .endif

Event CanvasPaint
  Switch_ ecx ; the canvas ID is in ecx
  Case_ TheImage
  .if MapRegion>=0
mov ecx, pics$(MapRegion) ; the image file, e.g. Capitals\00_Chisinau.jpg
GuiImage ecx, fit
void Extract$(ecx, "\", ".jpg") ; e.g. Capitals\Москва.jpg
GuiTextBox 100.0-114, 100.0-38, 110, auto, eax, bcol LiteGreen, font -20 ; lower right corner
.else
GuiTextBox 50.0-100, 50.0-80, 200, auto, "No country selected - click into the map", bcol LiteRed, font -40
.endif
  Case_ TheMap
ArrayPlot LiteBlue ; init and set background colour
PaintMap DarkGrey, lines=2 ; map with grey borders 2px thick
ArrayPlot exit, "Europe"
  Endsw_
GuiEnd


To build the source, use the latest MasmBasic version.

Vortex

Hi Jochen,

The second version works fine, thanks :thumbsup:

HSE

 :thumbsup:

A little problem with Zagreb.

Perhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on October 02, 2020, 10:53:29 PMA little problem with Zagreb.

Perhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.

Oops! Attached (and added to the online archive). You are right about the FileRead$ exceptions :thumbsup:

jj2007

Quote from: HSE on October 02, 2020, 10:53:29 PMPerhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.

This is fixed in the latest MasmBasic version:
include \masm32\MasmBasic\Res\MbGui.asm
Event Paint
  GuiImage "NoSuchImage.png", fit
GuiEnd


The solution costs a whopping 26 bytes of extra code and looks ugly, but it works :cool:

What exactly is the problem with FindOnDisk? Can you reproduce it? For me it works fine.

HSE

Quote from: jj2007 on October 03, 2020, 06:21:01 PM
What exactly is the problem with FindOnDisk? Can you reproduce it? For me it works fine.

If you miss something in "files to inclde in search" you have the exception

Trying to see if was solved:** Start D:\masm32\MasmBasic\Res\bldallRM.bat **
**** 32-bit assembly ****
OPT_Arg1: $ini=FindOnDisk.ini

*** Assemble, link and run FindOnDisk ***

*** Assemble using UASM32  ***
*** MasmBasic version 03.10.2020 ***
Tmp_File.asm(91) : Error A2102: Symbol not defined : dcRichEdit
DlgControl(41)[MasmBasic.inc]: Macro called from
  Tmp_File.asm(91): Main line code
Tmp_File.asm(91) : Error A2102: Symbol not defined : dcRichEdit
DlgControl(46)[MasmBasic.inc]: Macro called from
  Tmp_File.asm(91): Main line code
Tmp_File.asm(91) : Error A2102: Symbol not defined : dcRichEdit
DlgControl(87)[MasmBasic.inc]: Macro called from
  Tmp_File.asm(91): Main line code
Tmp_File.asm: 361 lines, 1 passes, 418 ms, 0 warnings, 3 errors
*** Assembly error ***
Equations in Assembly: SmplMath

jj2007

#21
Strange that you get assembler errors, here it works. Can you attach your source?

HSE

Hi JJ!

Perhaps you added some obsolete files in new installation. Setup ask for replacing files.

Binary was assembled with some previous MasmBasic version.

I think you don't have dcRichedit  :biggrin:  (well, I erased that)
Equations in Assembly: SmplMath

jj2007

Hi HSE,

Here is your modified source - search for changed (ini$, dcRichEdit, ...)

But I would strongly suggest to use the version in the second attachment.

There is also a bug in RichMasm: it adds °Bx bookmark tags when loading plain text files even if there is already a tag, so they accumulate with each save & reload. I never use plain text, so that little glitch evaded my attention. Will be fixed asap :cool:

jj2007

Version 3 of Capitals of Europe is attached to first post. No major changes, but
- the tooltips look nicer now, thanks to the XP manifest,
- they don't flicker any more (that is a genuine Windows bug),
- the names of Serbia and Russia are displayed in cyrillic to demonstrate that Unicode can be used

jj2007

An updated version of Capitals of Europe, tested on Windows XP, 7 and 10 :cool:



The source (attached) is a whopping 38 lines long :smiley:

NoCforMe

Tried running it. Was told "Maps are missing", asked if I want to download them. I clicked OK. It crashed. Olly screen shot attached; hopefully you can figure out where this is in your code.

[Windows 7-64 here]
Assembly language programming should be fun. That's why I do it.

jj2007

Thanks, I will have a look asap :thumbsup:

Do you have a Capitals folder in the executable's folder? If not, then your download was blocked.

HSE

Equations in Assembly: SmplMath

jj2007

Quote from: HSE on December 19, 2023, 10:53:22 PMNo problem here  :thumbsup:

Great, thanks for the feedback :thumbsup:

Here's one more, with a U.S. map (use left & right keys to browse by year):



Source (73 lines of purest Assembly, builds fine with Ml, UAsm, AsmC) & exe attached :cool:

If you insist on using MASM, i.e. \Masm32\bin\ml.exe, make sure it's a version 6.15 and greater but smaller or equal version 10. Recent versions have weird bugs; the proggie gets built, but it takes ages, and it doesn't run. My advice: use UAsm :cool: