Atari ST workshop 21/1/ Atari ST knowhow Workshop 2: Hardware and software hacks.

Slides:



Advertisements
Similar presentations
CPU Structure and Function
Advertisements

Lab 12 : Liquid Crystal Displays: Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 DMD Basics : Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 Data Write the.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
7/23 Coldfire Exceptions and Interrupts Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee
EECC250 - Shaaban #1 lec #16 Winter Estimation of Assembly Programs Execution Time For a CPU running at a constant clock rate: clock rate =
Computer System Overview
Chapter 7 Interupts DMA Channels Context Switching.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
CH11 Instruction Sets: Addressing Modes and Formats
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Code Generation CS 480. Can be complex To do a good job of teaching about code generation I could easily spend ten weeks But, don’t have ten weeks, so.
Counters and Registers
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Created in 2011 at Liberty High School. Getting Started Overview on Magnet Tool – Graphics – Text – Image – Video – Sound – Wall A Sample Glog How to.
IE433 CAD/CAM Computer Aided Design and Computer Aided Manufacturing Part-2 CAD Systems Industrial Engineering Department King Saud University.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
Agenda Last class: Memory, Digitizing Numbers Today: Digitizing: Text
Passing Parameters using Stack Calling program pushes parameters on the stack one element at a time before calling subroutine. Subroutine Call (jsr, bsr)
Chapter 11 Instruction Sets: Addressing Modes and Formats Gabriel Baron Sydney Chow.
Computer Organization 1 Instruction Fetch and Execute.
AT91 C-startup. 2 For reasons of modularity and portability most application code for an embedded application is written in C The application entry point.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
بسم الله الرحمن الرحيم MEMORY AND I/O.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
ColecoVision Opgrade Module
Input / Output Chapter 9.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Programmable System on Chip
Displacement (Indexed) Stack
Non Contiguous Memory Allocation
Addressing Modes the addressing mode defines how data is accessed
Memory and cache CPU Memory I/O.
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Subroutines … passing data
Day 08 Processes.
Day 09 Processes.
Computer Organization & Assembly Language Chapter 3
Introduction of microprocessor
Architecture Background
Addressing Modes Immediate #<data> or Imm
William Stallings Computer Organization and Architecture 8th Edition
Stack Frames Stack frame = block of memory located in the system stack that contains: return address input parameters (from calling program to subroutine)
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
1. Encode binary value using PCM
Lecture 3 - Instruction Set - Al
Subroutines … a 1st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with.
Software and Hardware Circular Buffer Operations
Interfacing with I/O Devices
Module 2: Computer-System Structures
Trying to avoid pipeline delays
Graphics Hardware: Specialty Memories, Simple Framebuffers
Today’s agenda Hardware architecture and runtime system
Logical Operations bitwise logical operations AND, OR, EOR, NOT
Computer Organization
Computer Architecture
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Module 2: Computer-System Structures
European Computer Driving Licence
Basic Instruction Cycle
Lecture 3 - Instruction Set - Al
Chapter 11 Processor Structure and function
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Register sets The register section/array consists completely of circuitry used to temporarily store data or program codes until they are sent to the.
ECE511: Digital System & Microprocessor
Presentation transcript:

Atari ST workshop 21/1/ Atari ST knowhow Workshop 2: Hardware and software hacks

Atari ST workshop 22/2/ What Hardware? ROM RAM keyboard MIDI MFP CPU Glue MMU shifter FDC DMA YM2149

Atari ST workshop 23/3/ Add RAM, RTC, HD, VIDEO...

Atari ST workshop 24/4/ Software hacks? Need to know: ● CPU ● Memory layout ● Video modes ● Peripheral registers

Atari ST workshop 25/5/ The CPU ● 8Mhz ● Orthogonal? ● 56 instructions / 14 address modes / 16 registers ● almost combinable each with each one ● Attention: big-endian (i.e. not Intel) ● 32 bit (but 16 bit bus) ● User mode / system mode

Atari ST workshop 26/6/ assembly Instructions ● Bcc, BRA, BSR, RTS, JMP, DBcc ● MOVE, MOVEQ MOVEM, MOVEP ● ADD, SUB, MUL, DIV ● AND, OR, EOR, NOT ● ASL, LSL, ROL, ROXL ● BTST, BSET, BCLR, BCHG ● SWAP, *BCD ● * SR, TRAP, TAS ● And many more.... Address modes ● Dn ● An ● (An) ● (An)+ ● -(An) ● x(An) ● x(An,Dn) ● xxx.W ● xxx.L ● x(PC) ● x(PC,Dn) ● #xxx ● SR

Atari ST workshop 27/7/ Memory layout & privileges | ROM | Reset: Supervisor Stack Pointer | ROM | Reset: Program Counter | RAM | 0 Kbyte RAM | RAM | 2 Kbyte RAM (start of user ram) | RAM | 512 Kbyte RAM | RAM | 1 Mbyte RAM fa 0000 | ROM | 320 Kbyte ROM fc 0000 | ROM | Reset: Supervisor Stack Pointer fc 0004 | ROM | Reset: Program Counter fc 0008 | ROM | 192 Kbyte ROM fe ffff | ROM | 0 Kbyte ROM ff 8000 | I/O | Configuration Registers ff 8200 | I/O | Display Registers ff 8400 | I/O | Reserved ff 8600 | I/O | DMA/Disk Registers ff 8800 | I/O | Sound Registers ff fa00 | I/O | MC68xxx Registers ff fc00 | I/O | MC68xx Registers Supervisor mode User mode Gemdos 32: Super(long stack) pea stack move.w #$20,-sp trap #1 Xbios 38: Supexec(long codeptr) pea codeptr move.w #$26,-(sp) trap #14 addq.l #6,sp and #$fff,SR Gemdos 32: Super(long stack) pea stack move.w #$20,-sp trap #1 Gemdos 32: Super(long stack) pea stack move.w #$20,-sp trap #1 Gemdos 32: Super(long stack) pea stack move.w #$20,-sp trap #1

Atari ST workshop 28/8/ Video chip ● Nice mix between shifter MMU and Glue ● Restriction: the screen base address has the low byte always $00, i.e. only 256 byte frontier ● Restriction: changing base address only has effect on next frame ● No direct colors on screen, but indexes into 16 colors palette ● Changing color value has immediate effect ● Think GIF but 16 instead of 256 colors

Atari ST workshop 29/9/ VIDEO memory Word interleaved with color lookup table Memory layout 320x200x4=256000bit=32000 bytes Grafic bitplanes 1 st pixel is composed of high order bits from words 0-3 (that's not GIF anymore) word 1word 2word 3word 4word 5word 6word 7word 0

Atari ST workshop 210/ Colorcycling / screen changing ● Uses no CPU ● Uses no additional RAM ● Very basic step animation up to 16 frames ● => neochrome pictures ● 512K RAM allows ● 16 different pictures ● 1MB has 32 steps ● Complex animations => shiny bubbles demo Both can be combined => pandemonium acid screen

Atari ST workshop 211/ Moving grafics ● up / down : welcome to movem.l instruction! ● 32000/200 = 160 bytes per line ● move.l $44E,a0 ; _v_bas_ad ● movem.l 160(a0),d0-d7 ; 32 bytes ● movem.l d0-d7,(a0)+ ; repeat 5 times Address mode not allowed, oh oh....

Atari ST workshop 212/ Moving grafics ● up / down : welcome to movem.l instruction! ● 32000/200 = 160 bytes per line ● move.l $44E,a0 ; _v_bas_ad ● lea 160(a0),a0 ● movem.l (a0)+,d0-d7 ; 32 bytes ● movem.l d0-d7, (a0) ; repeat 5 times

Atari ST workshop 213/ Moving grafics ● up / down : welcome to movem.l instruction! ● 32000/200 = 160 bytes per line ● move.l $44E,a0 ; _v_bas_ad ● lea 160(a0),a0 ● moveq #4,d0 ; repeat 5 times cpline: movem.l (a0)+,d1-d7/a1 ; 32 bytes movem.l d1-d7/a1, (a0) dbf d0,cpline

Atari ST workshop 214/ Moving grafics ● We copied 1 line, now copy whole screen ● move.l $44E,a0 ; _v_bas_ad ● lea 160(a0),a0 ● move.w #199,d1 cpscreen: ; screen wraps around at end of line moveq #4,d0 ; repeat 5 times cpline: movem.l (a0)+,d2-d7/a1-a2 ; 32 bytes movem.l d2-d7/a1-a2, (a0) dbf d0,cpline dbf d1,cpscreen

Atari ST workshop 215/ Moving grafics ● This can be optimized: 5*200=1000 ● move.l $44E,a0 ; _v_bas_ad ● lea 160(a0),a0 ● move.w #999,d0 ; repeat 1000x cpscreen: movem.l (a0)+,d2-d7/a1-a2 ; 32 bytes movem.l d2-d7/a1-a2, (a0) dbf d0,cpscreen

Atari ST workshop 216/ scrolling move.l $44E,a0 ; _v_bas_ad lea tmpbuf,a1 ; save top line moveq #4,d0 ; repeat 5 times bckppline: movem.l (a0)+,d1-d7/a2 ; 32 bytes movem.l d1-d7/a2,(a1) lea 32(a1),a1 dbf d0,bckppline move.l $44E,a0 ; _v_bas_ad lea 160(a0),a0 move.w #999-5,d0 ; repeat 1000x -1 line cpscreen: movem.l (a0)+,d2- d7/a1-a2 ; 32 bytes movem.l d2-d7/a1-a2, (a0) dbf d0,cpscreen move.l $44E,a0 ; _v_bas_ad adda.l # ,a0 lea tmpbuf,a1 moveq #4,d0 ; repeat 5 times cplineback: movem.l (a1)+,d1-d7/a2 ; 32 bytes movem.l d1-d7/a2,(a0) lea 32(a0),a0 dbf d0,cplineback [...] BSS tmpbuf: ds.b 160 ● Bring in new data on bottom

Atari ST workshop 217/ scrolling move.l $44E,a0 ; _v_bas_ad lea tmpbuf,a1 bsr linecopier move.l $44E,a0 ; _v_bas_ad move.w #199-1,d0 ; repeat 199x cpscreen: bsr linecopier dbf d0,cpscreen move.l $44E,a0 ; _v_bas_ad adda.l # ,a1 lea tmpbuf,a0 bsr linecopier [...] Linecopier: ; copy 32 bytes from (a0) to (a1) moveq #4,d0 ; repeat 5 times cpline: movem.l (a0)+,d1-d7/a2 ; 32 bytes movem.l d1-d7/a2,(a1) lea 32(a1),a1 dbf d0,cpline rts BSS tmpbuf: ds.b 160 ● We can make that shorter: sub routine This is slow!

Atari ST workshop 218/ Same scrolling, faster We could scroll 8 lines at a time oh, wait... 8*160=1280 and 1280 / 256 = 5 if we move the screen base address... copy 2 times the picture and have the screen move around Sliding window Apparent movemen t

Atari ST workshop 219/ Other direction ● Right to left, always right to left ● Picture ● Scrolltext ● Just a very long image ● Individual letters ● Need to have font handling routine

Atari ST workshop 220/ Horizontal scrolling ● 16 bit boundaries issue ● Scroll speed: the fastest is the easiest ● Speed/Memory tradeoff ● Shifting data: slow ● Preshifting: memory

Atari ST workshop 221/ Classic scrolltext 1) Read next text letter 2) Locate font data 3) Copy font data to buffer start 4) Copy buffer to screen 5) Shift buffer one position left 6) Wait vbl THIS IS MY FIRST SCROLLTEXT T T T ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ TH THI buffer text font buffer screen

Atari ST workshop 222/ How to shift ● Word shift: move each line 4 words left ● Every letter is 16 pixels wide ● That's the fast and easy scroll, it's also fast word 1word 2word 3word 4word 5word 6word 7word 0word 8word 9word Aword B

Atari ST workshop 223/ How to shift ● Byte shift is slower but easier readable ● Letters are 8 pixels wide ● More complex code word 0word 8word 9word Aword Bword 1word 2word 3word 4word 5word 6word 7

Atari ST workshop 224/ How to shift ● Bit shift: very smooth, lotsa CPU ● Need to lsl all the data ● Or multiple buffers, extreme case: 16 ● Maybe also have the font data on 16 shifts ● Speed memory tradeoff: scroll by 2 pixels

Atari ST workshop 225/ Distorter ● A logo moving left and right ● Add a wave = move each line individually ● Quite slow ● Preshifting is the key => 16 times the memory ● Left right boders: what about background? ● Masking with AND & OR

Atari ST workshop 226/ sprites ● A grafical object moving in all directions ● Example: mouse cursor ● Can be hollow, needs complete masking

Atari ST workshop 227/ The bitplane trick ● Less colors = less planes ● Less planes = faster code ● Free planes for other grafics = no masking ● Create cool transparency for free

Atari ST workshop 228/ Colors, more colors ● Pallette modification is immediate ● Favorite register: color 0, also shows in border ● Rasters ● Palette switching in middle of screen ● => 2x16 colors or more x16? ● Spectrum 512: 200 x 3 x 16 (48 / line)

Atari ST workshop 229/ Higher resolution ● Ugly border, only usable by background color ● Bottom border, how is it possible? ● V=vertival video (pixels are sent to screen) ● What the GLUE does on bottom screen: ● If line=234 && freq=60 then disable V ● If line=259 && freq=50 then disable V line 0 Switch here to 60Hz 43 lines more Shiraz didn't expect that...

Atari ST workshop 230/ Top border also ● Same thing, other play ● Same tests are done on top of screen ● If line=34 && freq=60 then enable V ● If line=59 && freq=50 then enable V line 0 25 lines more Switch here to 60Hz

Atari ST workshop 231/ And left/right borders ● Simply place some swithces ● Simply? Some? If hpos=93 and freq=60 then disable H If hpos=94 and freq=50 then disable H If hpos=13 and freq=60 then enable H If hpos=14 and freq=50 then enable H If hpos=0 and freq=70 then enable H Got you! 70Hz 50Hz 60Hz 50Hz You have to do this every line => holy grail of programming: synchron code Switch here to 60Hz

Atari ST workshop 232/ The Sync Scroll ● Invented by... TCB, perfected by Sync :-) ● Hardware scrolling: overcome the 256 limit ● Overscan “eats” data ● More or less lines overscan “move” display

Atari ST workshop 233/ Lines ● Yes! no grafic chip, no GL ● How to draw a line? ● Check start Main loop: x++ Error too big: y++ deltaerr=ylen/xlen (float) while x++ < xmax plot(x,y) error := error + deltaerr if error ≥ 0.5 then y := y + 1 error := error - 1.0

Atari ST workshop 234/ polygons ● Polygon is 2 lines, filled in between horizontally ● 3D grafics ● calculate coordinates ● Check hidden / sort in Z ● Draw lines or polygons

Atari ST workshop 235/ Digisound ● chiptune part will be handled in the radio show ● Output samples? Use volume registers ● 3 registes of 16 logarythmic values ● Need conversion table ● Slow: need to write 3 times on same address ● Fast: use shadow registers

Atari ST workshop 236/ Multiple voices ● Amiga has 4 voices in hardware ● Variable speed ● Volume control ● Brute force calculation: ST plays 4 voices too but uses almost 100% CPU ● Comes to the rescue: bresenham routine ● Line with variable slope sample with variable speed ● ST plays 8 voices and still has CPU time left ● see: forum.com/viewtopic.php?f=68&t=20168http:// forum.com/viewtopic.php?f=68&t=20168 ● (or wait for next workshops to digg deeper)

Atari ST workshop 237/ Next Workshops 3. Putting it all together 4. Assembler and Hardware 5. Algorithms and Optimizations 6. Sync programming 7. First own steps This is not finalized