• Forum
  • Lounge
  • Updating pre-C++11/Win32 API code to mod

 
Updating pre-C++11/Win32 API code to modern practices

For years I've been using the Win32 C++ code from "Sams Teach Yourself Game Programming in 24 Hours" to refine my use of modern C++/Win32 by tweaking the code.

The book was originally published in 2003, it is quite ancient in how it uses C++/Win32.

Both have evolved over the years (duh!) and trying to adapt the code to work with Win10 and C++11/20 has been a decent learning experience.

The code to load a bitmap file on the HD was atrocious! Replaced dozens of C-based code with a single Win32 function was one of the first tweaks I made.

Another tweak made was using auto to declare iterators instead of explicit declarations.

Now I'm reworking the code to use smart pointer instead of raw pointers. Strangely this is one of the easiest modifications that I remember, change a couple of lines when creating the pointer(s). I kept the use of pointer notation since that changing that from -> to . would be a large chunk of code to revise.
Here's an Amazon link if anyone is interested in getting the book.

https://www.amazon.com/Sams-Teach-Yourself-Programming-Hours/dp/067232461X/

Make sure you get the accompanying CD, the code examples in the book are not 100% complete. The class examples of each game are not stitched together, each function is a separate listing.

It's no longer published - just available second-hand. So I doubt that it would have the CD. I've tried this before with second-hand books by first asking the seller. The only replies I have had is that they don't know as the person dealing with enquires is divorced from the warehouse. A couple did say if not satisfied I could return it under their satisfaction policy. Ahhh...

As you're obviously done a lot of work with the provided code, why don't you put it up on github so others also using the book could benefit as well?
I know the book is only available as used. I have been (somewhat) thinking about sharing the code via github, but I've been rather lazy in doing so; I've been hesitant about sharing the code since it is copyrighted.

It would be a (hopefully) good learning experience in dealing with git, repositories, etc. I have not really done a lot with git other than getting a Win git client installed so it can manage vcpkg updates.

Code that is almost 2 decades old could be considered "abandonware." :Þ

I'll have to do some reading about managing git first. :)

I'll use this to mention (briefly) the trials and tribulations about sharing the code via git/github.

I do know github isn't the only available repository, but it is free and the code samples for the books/eBooks I own are hosted on github.

I do understand the aversion to github some people have, it is owned/operated by MS.

P.S., someone who's an experienced C++/Winows API programmer really wouldn't need the book, the game engine in the various 24 or so iterations is quite simple.

@seeplus, if you were to do this would you git the original code and post the revisions as they are done? Doing that would make sense and show others my thinking on the changes I've made over the years.

The project is still very much in a state of flux, working on modifying and updating the code.
I've been hesitant about sharing the code


Updated code for Petzold's "Programming Windows" is available on github
https://github.com/yottaawesome/programming-windows-5th-edition

So why not updated code for this book!

would you git the original code and post the revisions as they are done


I'd have 2 folders - one for the original code and one for your updated. Then probably various folders under these for each chapter/program etc - depending upon the book structure.

There are two Win32 game programming books by Michael Morrison I own and muck around with. For many of the chapters between the two books the game code is the same or very similar, though a couple of chapters do present different types of game engine setups.

Both have full source code on CD.

Sams Teach Yourself Game Programming in 24 Hours (2003)
https://www.amazon.com/Sams-Teach-Yourself-Programming-Hours/dp/067232461X/

Beginning Game Programming (2004)
https://www.amazon.com/Beginning-Game-Programming-Michael-Morrison/dp/0672326590/

I've been working with and reworking the code for so long that I no longer see the code examples as being from two separate books, I see the code as one combined on-disc repository.

There are other non-source files on the CDs. Bitmap artwork, WAV sound and MIDI music files. If I did git the code to an online repository should I include the non-code files as well?
Last edited on
The updated Petzold's book on github is part of my hesitancy in sharing the game engine sources. The original Win98 CD sources AFAIK aren't part of the github repository. Just the revised code.

But I'd like to "share" the original code so others could tweak it in different ways I never thought about.

I guess I'm just making excuses to be lazy about learning github and sharing the code.

Gi'e me some time and I'll get that darned "roundtoit." :Þ

https://www.amazon.com/s?k=roundtoit+coin&i=stripbooks&dc&crid=2NQ6LY8VCLHXP&sprefix=roundtoit+coin%2Cstripbooks%2C264&ref=a9_asc_1

If I shared the original code the publisher could request it be taken down. meh.

It isn't as if I were sharing the book's text in electronic form.
Last edited on
I already have a github account, under a user name I no longer use and would like to change.

M'ok, George P isn't my real name either, I tend to prefer to hide my meat world identity.

But changing my github account name from FurryGuy to some variant of my current username George P ain't gonna happen without a lot of extra letters that I don't like. ::sad::

Who knew other people like/have the real name George-P?!?

George P is short for "George Pimpleton." A somewhat take-off of "George Plimpton." Why? I don't remember. :Þ

https://en.wikipedia.org/wiki/George_Plimpton
Last edited on
Well, changing my github account user name to GeorgePimpleton was doable! HUZZAH!

*happy dance!*
I also deleted an ooooooooold forked repository (NearInfinity) I had made back in 2013 when I first created my github account. *WHOA!*

M'ok, going through this process really shows me I do need to learn git. At least if I muck things up I kinda sorta know how to slash and burn things to start over.
M'ok, I've got a new "shiny thing" to play with and be-dazzle me, github. :)

Changed out my old, still usable, email address for a new one that better reflects my current user name.

https://github.com/GeorgePimpleton

Have fun, peeps, trashing the place. :D
One last question, seeplus, before I start working on my game engine repository....

Since I use two books with very similar code should I create two separate repositories, or do a single repository with sub-dirs for each book sources? original and revised.

Yes, I plan on having the game code in a new repository separate from my main personal repository. :)
Last edited on
Well, I can't say it is perfect, but I've committed some files to github.

https://github.com/GeorgePimpleton

Suggestions for improvement appreciated.

Criticism might take some time to stop the tantrum and process what's said.
Doing the editing on my local HD is much less painful than I thought it would be, making committing and pushing any changes easy.
Well, I've got the original and updated code for several of the "games" if'n anyone wants to look and laugh at my attempts to modernize old pre-C++11 Win32 code.

https://github.com/GeorgePimpleton/Win32-games

This "announcement" is probably gonna be the last one, anyone who wants to look can do so without the reminders.

Continuing to mention the github as I work on this personal project would be a bit of annoying self-promotion. :Þ
Last edited on
seeplus wrote:
Updated code for Petzold's "Programming Windows" is available on github

Another github repository that is updating Petzold's old 1998 Win API code. Neato. *adds to my list*

A number of years ago I ran across this repository:

https://github.com/recombinant/petzold-pw5e

This repository does a bit more extensive changing to the source files to bring it up to modern standards.

The amount of work done to revamp the Win API code is in part where I got the idea of doing something similar to the game code.
Last edited on
Topic archived. No new replies allowed.