# Highrise A tower-building management game for the Commodore 64 (PAL), written in cc65 C with assembly for drawing and interrupts. You build a skyscraper floor by floor, fill it with offices, condos and restaurants, and keep people moving with elevators and stairs. ## Running it ``` pwsh tools/c64.ps1 run projects/highrise -ViceArgs "-mouse -controlport1device 3" ``` This puts a 1351 mouse in control port 1. Click in the VICE window and press **Alt+Q** to capture the mouse (press it again to release). You can also set the mouse up from the menus: *Settings > Input devices > Control port 1: Mouse (1351)* and *Enable mouse grab*. ## Playing | Control | Action | |---------|--------| | Click a toolbar entry | Choose what to build: floor, lobby, stairs, elevator, office, condo, food, clear | | Left click in the tower | Build. Drag sideways for floor and lobby; drag up or down for an elevator | | Right button | Cancel a drag | | Mouse at the screen edge, cursor keys, W A S D | Scroll | | Space | Pause or resume | | 1 to 8 | Speed: 1, 2, 3, 4, 6, 8, 12 or 16 times normal | | + and - | Mouse speed (1-8, starts at 3) | | Click the speed sign (top right) | Next speed (after 8: pause) | | X | Load a sample tower (only on an empty lot) | The message line shows what the pointer is over: the cost of a build, why it can't go there, or a room's status. **Getting started:** build a lobby along the ground floor. Add floors above it, an elevator from the lobby up, then offices. Tenants move in when they can get from the lobby to their floor. ## Rules - **Floors** need support below them. Basements are dug down from the floor above and need 2 stars. - **Offices** (6 wide) pay $1000 rent every day at 17:00. Six workers arrive in the morning, some go out for lunch, and they leave in the evening. - **Condos** (8 wide) sell for $150,000 when a family moves in. They leave in the morning and come home in the evening. - **Fast food** (8 wide) earns $15 per guest: workers at lunch, residents at dinner, and visitors from outside. Busier towers bring more visitors. - **Elevators** span up to 30 floors and carry 15 people; each costs $300 a day. Stairs link one floor to the next. People change shafts when needed. - **Stress:** people waiting at an elevator are shown at its door: white for a few, yellow for many, red for a crowd. Tenants whose people wait too long rate the tower poor, and after two poor days they move out. - **Stars** come with population (100, 300, 700, 1500) and let the tower grow: 15 floors at one star, then 25, 40 and 60. ## Inside | File | Contents | |------|----------| | `src/main.c` | Setup, input, toolbar and status bar, the elevator cars, the self-test | | `src/world.c` | Building and bulldozing, the cell and tile maps | | `src/sim.c` | Trips, routing, elevators, people's daily schedules, money and ratings | | `src/render.s` | Drawing the view, the raster splits, the mouse pointer callbacks | | `tools/gen_gfx.py` | Generates the tiles, tile pairs and sprites (`src/gfx.c`, `src/gfx.h`) | Memory: the screen ($E800), character set ($E000) and sprites ($EC00) are in VIC bank 3, in the RAM under the Kernal ROM. The map is at $A000-$B3FF, one byte per cell indexing a pair of tiles. The cell-ownership grid is at $B400-$C7FF. BASIC ROM is switched out. Two raster splits give the sky its own background color, which follows the time of day. The mouse is read by the game itself (`render.s`), not cc65's driver, twice a frame (in both raster interrupts). A 1351 reports its position modulo 128, so the change between two readings is only unambiguous under 64 counts; reading often keeps a fast flick from wrapping and throwing the pointer the wrong way. Movement is scaled by the mouse speed. While a button is held, the keyboard scan is skipped so the button can't type phantom keys. `c64 test projects/highrise` builds a sample tower, runs it through a working day, and checks that every worker came and went, rent was paid, nobody gave up waiting, and that building and bulldozing follow the rules. The day takes about a minute of C64 time, so it runs only when the test types T at startup.