The MASM Forum

Members Gallery => Showcase => Topic started by: jj2007 on September 25, 2020, 01:51:46 AM

Title: Capitals of Europe
Post by: jj2007 on September 25, 2020, 01:51:46 AM
Extract the attached archive to any folder, then run the exe; afterwards, click into the map to see an image showing the country's capital. Might be useful as a geography lesson ;-)

Congrats to those who are able to find and select Jan Mayen, the Faeroe Islands, the Isle of Man and Malta :tongue:
Title: Re: Capitals of Europe
Post by: Vortex on September 25, 2020, 03:10:46 AM
Hi Jochen,

I turned off Windows Defernder but Windows 10 Version 1909 seems to block the application. The application displays a gray colored window disappearing after some seconds.
Title: Re: Capitals of Europe
Post by: HSE on September 25, 2020, 03:20:51 AM
CPU Disasm
Address   Hex dump          Command                                  Comments
00401EEC  |.  58            POP EAX
00401EED  |.  FF32          PUSH DWORD PTR DS:[EDX]
00401EEF  |.  8B52 10       MOV EDX,DWORD PTR DS:[EDX+10]
00401EF2  |.  33C9          XOR ECX,ECX
00401EF4  |>  AC            /LODS BYTE PTR DS:[ESI]
00401EF5  |.  24 1F         |AND AL,1F
00401EF7  |.  8844CA 04     |MOV BYTE PTR DS:[ECX*8+EDX+4],AL  <<<<<<<<<<< Access violation when writing
00401EFB  |.  41            |INC ECX
00401EFC  |.  3B0C24        |CMP ECX,DWORD PTR SS:[ESP]
00401EFF  |.^ 72 F3         \JB SHORT 00401EF4
00401F01  |.  5A            POP EDX
00401F02  |.  5E            POP ESI
00401F03  |.  59            POP ECX
00401F04  |.  6A 00         PUSH 0                                   ; /Arg4 = 0
00401F06  |.  6A 00         PUSH 0                                   ; |Arg3 = 0
00401F08  |.  6A 07         PUSH 7                                   ; |Arg2 = 7
00401F0A  |.  68 78E14000   PUSH OFFSET 0040E178                     ; |Arg1 = ASCII "Capitals\Capitals.ini"
00401F0F  |.  E8 E83F0000   CALL 00405EFC                            ; \MapsAndPhotos.00405EFC
00401F14  |.  53            PUSH EBX
00401F15  |.  E8 300B0000   CALL <JMP.&user32.CreatePopupMenu>       ; [USER32.CreatePopupMenu
Title: Re: Capitals of Europe
Post by: jj2007 on September 25, 2020, 04:05:33 AM
Quote from: HSE on September 25, 2020, 03:20:51 AM
00401EF7  |.  8844CA 04     |MOV BYTE PTR DS:[ECX*8+EDX+4],AL  <<<<<<<<<<< Access violation when writing

It does that if you don't follow the instructions. The exe needs the images.

Quote from: jj2007 on September 25, 2020, 01:51:46 AMExtract the attached archive to any folder, then create in that folder a subfolder Capitals and extract all files from this archive (http://www.jj2007.eu/images/Capitals.zip) to that folder.

Quote from: Vortex on September 25, 2020, 03:10:46 AM
Hi Jochen,

I turned off Windows Defernder but Windows 10 Version 1909 seems to block the application. The application displays a gray colored window disappearing after some seconds.

Sorry for that, Erol. It works fine here...
This is Windows version 10.0, build 18362
The long story: Windows version 10.0 1903, build 18362
running on Intel(R) Celeron(R) CPU  N2840  @ 2.16GHz
Title: Re: Capitals of Europe
Post by: Vortex on September 25, 2020, 05:58:46 AM
Hi Jochen,

My apologies, I didn't download the zip archive containing the images. Now, it works fine. Nice work :thumbsup:
Title: Re: Capitals of Europe
Post by: HSE on September 25, 2020, 08:09:24 AM
Fantastic JJ  :thumbsup:

I almost have forgotten that Europe is an island.  :biggrin: :biggrin:
Title: Re: Capitals of Europe
Post by: jj2007 on September 25, 2020, 09:03:06 AM
Thanks for testing, Erol & HSE. The map is old, unfortunately, it is very difficult to find good free maps on the web. So Russia is missing, and the Balkan is not quite up-to-date. For a demo it's ok, though ;-)
Title: Re: Capitals of Europe
Post by: guga on September 25, 2020, 11:40:28 AM
One word. WOW !!!!  :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup:
Title: Re: Capitals of Europe
Post by: Siekmanski on September 25, 2020, 04:41:48 PM
Cool!  :cool:
Title: Re: Capitals of Europe
Post by: TimoVJL on September 25, 2020, 05:24:49 PM
Europe in WMF-format:
https://d-maps.com/carte.php?num_car=30080&lang=en
Title: Re: Capitals of Europe
Post by: avcaballero on September 25, 2020, 06:16:37 PM
Maybe a bit offtopic here, or maybe not.

The four colours theorem: (https://en.wikipedia.org/wiki/Four_color_theorem#:~:text=In%20mathematics%2C%20the%20four%20color,regions%20have%20the%20same%20color.)
Title: Re: Capitals of Europe
Post by: jj2007 on September 25, 2020, 06:23:01 PM
Quote from: TimoVJL on September 25, 2020, 05:24:49 PM
Europe in WMF-format:
https://d-maps.com/carte.php?num_car=30080&lang=en

Thanks, Timo. Nice but:
239358 svg
574416 wmf
36464 map (my format)
Title: Re: Capitals of Europe
Post by: hutch-- on September 25, 2020, 11:21:59 PM
If you don't mind a few tiny JPG artifacts, you can get Timo's image down to 33k and it still looks OK.
Title: Re: Capitals of Europe
Post by: jj2007 on September 26, 2020, 01:51:36 AM
Quote from: hutch-- on September 25, 2020, 11:21:59 PM
If you don't mind a few tiny JPG artifacts, you can get Timo's image down to 33k and it still looks OK.

It needs to be a vector format - the map is not an image. In the meantime I found a map of Europe, very nice and 25k only.
Title: Re: Capitals of Europe
Post by: daydreamer on September 26, 2020, 06:18:13 AM
Great Jochen :thumbsup:
Title: Re: Capitals of Europe
Post by: jj2007 on October 02, 2020, 07:59:30 PM
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 (http://masm32.com/board/index.php?topic=94.0).
Title: Re: Capitals of Europe
Post by: Vortex on October 02, 2020, 08:50:13 PM
Hi Jochen,

The second version works fine, thanks :thumbsup:
Title: Re: Capitals of Europe
Post by: HSE on October 02, 2020, 10:53:29 PM
 :thumbsup:

A little problem with Zagreb.

Perhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.
Title: Re: Capitals of Europe
Post by: jj2007 on October 02, 2020, 11:11:43 PM
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:
Title: Re: Capitals of Europe
Post by: jj2007 on October 03, 2020, 06:21:01 PM
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 (http://masm32.com/board/index.php?topic=94.0):
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.
Title: Re: Capitals of Europe
Post by: HSE on October 04, 2020, 01:43:39 AM
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 ***
Title: Re: Capitals of Europe
Post by: jj2007 on October 04, 2020, 08:29:12 AM
Strange that you get assembler errors, here it works. Can you attach your source?
Title: Re: Capitals of Europe
Post by: HSE on October 04, 2020, 09:45:19 AM
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)
Title: Re: Capitals of Europe
Post by: jj2007 on October 04, 2020, 02:03:22 PM
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:
Title: Re: Capitals of Europe
Post by: jj2007 on October 11, 2020, 09:55:55 PM
Version 3 of Capitals of Europe is attached to first post (http://masm32.com/board/index.php?topic=8808.0). 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 (https://www.vbforums.com/showthread.php?706379-RESOLVED-jcButton-Balloon-tooltips-flicker-when-themed-(manifest)-applied)),
- the names of Serbia and Russia are displayed in cyrillic to demonstrate that Unicode can be used
Title: Re: Capitals of Europe
Post by: jj2007 on December 18, 2023, 12:52:04 AM
An updated version of Capitals of Europe, tested on Windows XP, 7 and 10 :cool:

(http://www.jj2007.eu/pics/JanMayen.jpg)

The source (attached) is a whopping 38 lines long :smiley:
Title: Re: Capitals of Europe
Post by: NoCforMe on December 19, 2023, 11:33:18 AM
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]
Title: Re: Capitals of Europe
Post by: jj2007 on December 19, 2023, 01:51:17 PM
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.
Title: Re: Capitals of Europe
Post by: HSE on December 19, 2023, 10:53:22 PM
No problem here  :thumbsup:
Title: Re: Capitals of Europe
Post by: jj2007 on December 20, 2023, 03:57:45 AM
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):

(http://www.jj2007.eu/pics/UsIncome.png)

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 (http://www.terraspace.co.uk/uasm.html#p2) :cool: