惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
U
Unit 42
W
WeLiveSecurity
博客园 - Franky
Recent Announcements
Recent Announcements
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
月光博客
月光博客
The Cloudflare Blog
Spread Privacy
Spread Privacy
腾讯CDC
P
Privacy International News Feed
N
News and Events Feed by Topic
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
T
Troy Hunt's Blog
小众软件
小众软件
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Microsoft Security Blog
Microsoft Security Blog
L
Lohrmann on Cybersecurity
Webroot Blog
Webroot Blog
Y
Y Combinator Blog
量子位
P
Palo Alto Networks Blog
N
News and Events Feed by Topic
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
IT之家
IT之家
T
Threat Research - Cisco Blogs
Cloudbric
Cloudbric
云风的 BLOG
云风的 BLOG
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
G
Google Developers Blog
S
Secure Thoughts

Secret Weblog

Becoming More Xee: A Modern XPath and XSLT Engine in Rust Looking for new challenges! Repeat Yourself, A Bit The Curious Case of Quentell The Humble For Loop in Rust The Humble For Loop in JavaScript Don Question Best Practices I Was a 1980s Teenage Programmer Part 5: Achieving Assembly The Tooling Shift I Was a 1980s Teenage Programmer Part 3: MSX-2 JavaScript: when you need two ways to do it! Empowering Programming Languages Bloat and Retrofuturism Refreshing my Blog Again Random Rust Impressions Apilar: An Alife System I Was a 1980s Teenage Programmer Part 2: Olivetti M24 I Was a 1980s Teenage Programmer: the Alphatronic SolidJS fits my brain Is premature optimization the root of all evil? Framework Patterns: JavaScript edition Roll Your Own Frameworks Framework Patterns Secret Weblog Highlights Refactoring to Multiple Exit Points mstform: a form library for mobx-state-tree Seven Years: A Very Personal History of the Web Morepath 0.16 released! Is Morepath Fast Yet? Introducing Bob Strongpinion Punctuated Equilibrium in Software Morepath 0.15 released! Impressions of React Europe 2016 Morepath 0.14 released! Morepath 0.13 now with Dectate Dectate: advanced configuration for Python code JavaScript Dependencies Revisited: An Example Project The Incredible Drifting Cyber A Brief History of Reselect The Emerging GraphQL Python stack Thoughts about React Europe Build a better batching UI with Morepath and Jinja2 GraphQL and REST Server Templating in Morepath 0.10 10 reasons to check out the Morepath web framework in 2015 A Review of the Web and how Morepath fits in Morepath 0.9 released! Better REST with Morepath 0.8 Morepath 0.7: new inter-app linking They say something I don Life at the Boundaries: Conversion and Validation BowerStatic 0.4 released! Morepath 0.6 released! Morepath 0.5(.1) and friends released! New HTTP 1.1 RFCs versus WSGI Against On Naming In Open Source My visit to EuroPython 2014 Morepath 0.4.1 released (with Python 3 fixes) Morepath 0.4 and breaking changes Announcing BowerStatic Morepath 0.3 released! Morepath 0.2 Morepath Python 3 support The Call of Python 2.8 Morepath 0.1 released! WebOb and Werkzeug compared Morepath: from Werkzeug to WebOb Racing the Morepath: SQLAlchemy Integration The Centre Cannot Hold Breaking Morepath Changes Morepath Update How to do REST with Morepath Morepath Security the Gravity of Python 2 #python2.8 discussion channel on freenode Alex Gaynor on Python 3 Morepath Documentation Starting to Take Shape Back to the Center Morepath App Reuse Implementing Grok Grok: the Idea Why Linux Works for Me On the Morepath Reg, Now With More Generic! The New Zope as a Web Framework Jim Fulton, Zope Architect Renewing Zope Object Publishing The Weirdness of Zope The Rise of Zope My Exit from Zope Reg: Component Architecture Reimagined JSConf EU 2013 impressions Obviel 1.0! JS Dependency Tools Redux Obviel 1.0rc1 released! Succinct data structures
I Was a 1980s Teenage Programmer Part 4: The Call of Assembly
Martijn Faassen · 2024-05-31 · via Secret Weblog

This is Part 4 of a series.

Creating games with BASIC

Me and my friend were on a quest to develop games for the MSX-2. Creating "real" games seemed more in reach back then - the graphics were simple, there was no 3D, so we had the hope we could do it. Our skills weren't great, and BASIC was too slow for this purpose, but we had fun and learned many things.

MSX BASIC had a lot of high level commands to do graphics (and sound too). You could draw a line and a circle, you could define and move around sprites, you could copy bitmapped graphics to other areas of the screen.

Using POKE and PEEK to directly change and access memory was possible, and some other platforms like the Commodore 64 required that to do anything cool, but to me, POKE and PEEK remained a mystery and weren't really necessary to know about. I knew that if I POKEed the wrong place it would crash the machine.

Elite

At some point my friend and I obtained the game Elite, which was released on the MSX. This game was wildly different: unlike a 2d game with a fixed, simple action-oriented mission, like almost all other games on the platform, it was an open world 3d game where you were a space trader and you could roam a giant universe of stars trading your wares and fighting.

It was different. It was an extremely impressive game to us then. I'm even more amazed by it today and if you're a software developer, you will be as well if you watch this video:

No matter how ambitious I and my friends were about creating real games on the MSX, I don't remember we ever had any ambition to create something like Elite. We knew it was beyond us.

My friend and I knew the MSX could do smooth vertical scrolling. We'd seen games do it. But we didn't know how to do it from BASIC. There was no command. Until one day my friend had made a major discovery: the magical "VDP(24)" command. I don't know anymore how he had learned about it, but it changed our world. Suddenly we had access to a whole new ability!

Many years later I learned that VDP stands for Video Display Processor and that VDP(24) controlled register 23 (but BASIC started to count at 1 for this). This was like POKE and PEEK; a feature not fully exposed to BASIC.

Many years later as well, on a whim, I googled how to do vertical scrolling on the MSX-2. Even though this platform by then was very obsolete, I immediately found many resources that described how to do it. You still can. What was such a breakthrough for us was a trivial search away in the internet era.

Smooth horizontal scrolling on the MSX-2 was not possible with an equivalent VDP command.

Many side-scrolling games existed on the MSX, such as the famous Nemesis series made by Konami (more commonly known as Gradius was named on the MSX), but they all used character-tile based scrolling, which wasn't smooth:

Yet in 1989 we saw a new game in the Gradius genre, Space Manbow, also made by Konami, that had smooth horizontal scrolling. But we knew there was no hardware support for this. How did they do it?

We figured it out, and it was pretty insane:

There was a special VDP register that let you adjust the horizontal and vertical centering of the whole screenThis is Part 3 of a series.. It was actually exposed with a proper BASIC command, called SET ADJUST. You could recenter the screen from -7 to +8 pixels both horizontally and vertically.

Space Manbow adjusted the screen horizontally for 16 pixels, so scrolling was smooth, and then do a tile-based "jumpy" scroll after that, at the same time setting the adjust back to the extreme other end. This way each tile could scroll smoothly. It used black sprites to mask over the left and right sides of the screen, so you couldn't see the edge shifting.

BASIC KUN

A temporary reprieve arrived in the form of MSX-BASIC KUN, also known as X-BASIC. This was a BASIC compiler, but it didn't come in the shape of a compiler. There wasn't a program to translate your BASIC into machine code. Instead you gained a new BASIC command, CALL TURBO ON, which would enable this magic. You could surround your BASIC code with CALL TURBO ON and CALL TURBO OFF blocks and that code would be a LOT faster; online I read from 15 to 100 times faster. There were a few restrictions to the BASIC you could write in a turbo block. But it was like sorcery. We had no real idea how it could even work, but it did.

Lightbulb

But we knew that to write REAL games we'd have to learn assembly. But I just didn't get even the fundamentals.

At one point at school I talked to a guy who had done assembly. I asked him how I could do an IF in assembly (a conditional statement). He gave me the revelation: you'd first execute an arithmetic instruction, like substract. Then if the result of this operation was zero, the Z flag would be set. Then you used a conditional jump instruction, that would only jump if Z was set (or the inverse, when it wasn't set).

A lightbulb went off over my head. So that is how you do it!

I think still remember where I was when I was talking to him, on the ground floor of the school near where the coat hangers were, though I don't remember his face or name.

Next time...

Thanks for reading part 4 of this series! Next time we'll discuss me actually writing Z80 assembly code.