|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
Now I can rotate and zoom it in and out with keyboard control, it's kinda hypnotic watching it do its thing. If you see a line that's 66644464646464 it's because I mapped the keypad keys 4 and 6 to rotation and 5 and 2 to zoom. There's no line draw function into a bitmap so I ripped one off of irobot's driver that works ok. That's how I draw the red rectangle that shows the printhead location. I also learned that I can type PRINT#1"TEXT" instead of PRINT #1;"TEXT". So if I have a line of basic code that is 5 PRINT#1"TEXT" If I type RUN 5 from the immediate command line it closes the open file #1, but if I GOTO 5 or GOSUB 5 it doesn't close the open file.
|
|
|
|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
|
|
|
|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
I was trying to get Cyclod running with the sirius joyport, but for some reason I couldn't get it to select the joyport. Supposedly you enable the atari joystick with CTRL+SHIFT+P (which is actually CTRL+@). CTRL+P will enable the normal apple joystick. Sirius freefall and snakebyte wants CTRL+SHIFT+P too: https://archive.org/details/Cyclod/page/n1https://archive.org/details/1982-sirius-freefall/page/n1https://archive.org/details/sirius_snakebyte_manual/page/n1This puzzled me because none of these seem to work. So let's start digging: I looked at the code inside cyclod for reading the joyport and sure enough, it's got code that hits c05a and c05b
>find 0,bfff,5a,c0
Found at 869D
Found at 882B
Found at 8CB5
[MAME]>
>find 0,bfff,5b,c0
Found at 86BE
[MAME]>
and there's a joyport reading routine at 8699, but why doesn't it get called? let's watch what is actually reading from the keyboard and that leads us to the code where it reads the keyboard:
wp c000,1,r,1,{printf "keyboard read: pc=%x wpaddr=%x wpdata=%x ",pc,wpaddr,wpdata;g}
7398: AD 00 C0 lda KBD / 80STOREOFF
739B: 8D 27 70 sta $7027
739E: AD 10 C0 lda KBDSTRB
73A1: AD 5E 70 lda $705e
73A4: C9 01 cmp #$01
73A6: F0 06 beq $73ae
73A8: 20 99 86 jsr $8699 so our joyport routine will get called if there isn't a 1 in 705e we can find these routines by looking for where 7027 and 705e get accessed:
>find 0,bfff,5e,70
>find 0,bfff,27,70
8D7D: AD 27 70 lda $7027 keycode gets put here
8D80: C9 8B cmp #$8b 8b = CTRL+K keyboard
8D82: D0 09 bne $8d8d
8D84: A9 00 lda #$00 puts 00 in 705e
8D86: 8D 5E 70 sta $705e
8D89: 20 BC 82 jsr $82bc calls some other stuff
8D8C: 60 rts
8D8D: C9 90 cmp #$90 90 = CTRL+P joystick
8D8F: D0 09 bne $8d9a
8D91: A9 01 lda #$01 puts 01 in 705e
8D93: 8D 5E 70 sta $705e
8D96: 20 84 7D jsr $7d84
8D99: 60 rts
8D9A: C9 80 cmp #$80 80 = CTRL+shift+p or CTRL+@
8D9C: D0 08 bne $8da6
8D9E: A9 02 lda #$02 puts 02 in 705e
8DA0: 8D 5E 70 sta $705e
8DA3: 20 E6 76 jsr $76e6
8DA6: 60 rts
very similar routines to those above reading CTRL+k,CTRL+P,CTRL+@
8DA7: AD 27 70 lda $7027
8DAA: C9 8B cmp #$8b
8DAC: D0 06 bne $8db4
8DAE: A9 00 lda #$00
8DB0: 8D 5E 70 sta $705e
8DB3: 60 rts
8DB4: C9 90 cmp #$90
8DB6: D0 06 bne $8dbe
8DB8: A9 01 lda #$01
8DBA: 8D 5E 70 sta $705e
8DBD: 60 rts
8DBE: C9 80 cmp #$80
8DC0: D0 05 bne $8dc7
8DC2: A9 02 lda #$02
8DC4: 8D 5E 70 sta $705e
8DC7: 60 rts so the code is there but it's looking for a keycode of 0x80, but we're not getting it. Looking at the key table in src/mame/drivers/apple2.c we can fix the table to send a 0x00 code: static const uint8_t a2_key_remap[0x32][4] =
{
/* norm shft ctrl both */
{ 0x33,0x23,0x33,0x23 }, /* 3 # 00 */
{ 0x34,0x24,0x34,0x24 }, /* 4 $ 01 */
{ 0x35,0x25,0x35,0x25 }, /* 5 % 02 */
...
{ 0x55,0x55,0x15,0x15 }, /* u U 10 */
{ 0x49,0x49,0x09,0x09 }, /* i I 11 */
{ 0x4f,0x4f,0x0f,0x0f }, /* o O 12 */
{ 0x50,0x40,0x10,0x00 }, /* p P 13 */ //should be a 0x00 for a CTRL_SHIFT_P
{ 0x44,0x44,0x04,0x04 }, /* d D 14 */
{ 0x46,0x46,0x06,0x06 }, /* f F 15 */
{ 0x47,0x47,0x07,0x07 }, /* g G 16 */
{ 0x48,0x48,0x08,0x08 }, /* h H 17 */
{ 0x4a,0x4a,0x0a,0x0a }, /* j J
but we still don't get an 0x80 code because of an if statement in ay3600_data_ready_w that checks to see if our translated character is zero: commenting that out we now get the 0x80 code when we read $c000! Yay!
WRITE_LINE_MEMBER(apple2_state::ay3600_data_ready_w)
{
if (state == ASSERT_LINE)
{
int mod = 0;
m_lastchar = m_ay3600->b_r();
mod = (m_kbspecial->read() & 0x06) ? 0x01 : 0x00;
mod |= (m_kbspecial->read() & 0x08) ? 0x02 : 0x00;
m_transchar = a2_key_remap[m_lastchar&0x3f][mod];
// if (m_transchar != 0)
{
m_strobe = 0x80;
// printf("new char = %04x (%02x)\n", m_lastchar&0x3f, m_transchar);
}
}
}
|
|
|
|
Joined: Mar 2001
Posts: 17,234 Likes: 260
Very Senior Member
|
Very Senior Member
Joined: Mar 2001
Posts: 17,234 Likes: 260 |
Thanks! I'll fix that in mainline.
|
|
|
|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
Thanks, RB! I've got some fixes for the sirius joyport that I'll submit a PR for once I've fixed up my git. Here's the relevant bits (I think this is correct now:)
READ_LINE_MEMBER(apple2_joyport_device::sw0_r)
{
u8 port_read = m_an0 ? m_player2->read() : m_player1->read();
return BIT(port_read, 4);
}
READ_LINE_MEMBER(apple2_joyport_device::sw1_r)
{
u8 port_read = m_an0 ? m_player2->read() : m_player1->read();
return m_an1 ? BIT(port_read, 0) : BIT(port_read, 3);
} // 0 is up 3 is left
READ_LINE_MEMBER(apple2_joyport_device::sw2_r)
{
u8 port_read = m_an0 ? m_player2->read() : m_player1->read();
return m_an1 ? BIT(port_read, 2) : BIT(port_read, 1);
} // 2 is down 1 is right
I did some reading at https://git-scm.com/book/en/v2 and I think I'm finally getting closer to understanding git. It's hard to fathom, but there's no 2 player games I could find that really use the sirius joyport. I think there's a dearth in general of 2 player games on the apple 2, probably because very few people had more than 1 joystick. (I wonder how hard it would be to patch the karateka 2 player patch to use the joyport?) The only game that really tested out the 2 player setting is boulderdash where it alternates between joystick 1 and 2. Vindicators actually uses the second joystick, which is kinda different. Most use the first joystick, like stellar 7. There's a Computer Foosball game that uses the 4 paddle mode of the sirius joyport (you can hook up 2x2 paddle controllers and play with 2 teams of each paddle and button controlling one group of foosball flippers). I copied your joystick device and modified it to do the joyport with paddles, I called it joyportpaddle. You hit Ctrl+R to reset then you can choose 1 / 2 / 4 player with the 1,2,and 4 keys. Once a game has started you can't change the number of players but you can type N or F for Normal/Fast. The 4 player mode says "requires JOYPORT." The ball tends to get stuck so you have to hit Ctrl+B to do another serve. This is probably the only game that used the 4 paddle mode. (That would be good for a warlords type game). // This should be m_joy_y
u8 apple2_joyportpaddle_device::pdl3_r()
{
return m_joy_y[1]->read();
}
READ_LINE_MEMBER(apple2_joyportpaddle_device::sw0_r)
{
return m_an0 ? BIT(m_buttons->read(), 6) : BIT(m_buttons->read(), 4);
// m_an0 true = bit 6 false = bit4
// this makes sense for normal two player with a single paddle,
// we read bits 4 and 5 on switch 0 and 1
// For 4 paddles, we read bits 6 and 7 on switch 0 and 1 when m_an0 is true
}
READ_LINE_MEMBER(apple2_joyportpaddle_device::sw1_r)
{
return m_an0 ? BIT(m_buttons->read(), 7) : BIT(m_buttons->read(), 5);
}
READ_LINE_MEMBER(apple2_joyportpaddle_device::sw2_r)
{
return 0;
}
READ_LINE_MEMBER(apple2_joyportpaddle_device::sw3_r)
{
return 0;
}
Last edited by Golden Child; 09/06/19 11:55 PM.
|
|
|
|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
I thought I'd try all the games in the sirius collection as they'd be the ones most likely to have sirius joyport support. So far I've found that bandits, hadron, buzzard bait, freefall work with the joyport. Copts and robbers is a curious case. It has code to read the joyport, but it just doesn't work, moving the character only when the fire button is pressed and then backwards and diagonally to the upper left. Copts and robbers is a loose clone of adventure, down to the use of a magnet and a block representing the player's character. The manual doesn't mention the joyport. https://mocagh.org/miscgame/coptsrobbers.pdfCTRL+shift+P activates the joyport, CTRL+K goes back to keyboard. I looked and looked at the code at 1f40 and it just doesn't work because the joyport has buttons that are active low, hi bit set when pressed. If we change the BMIs to BPLs and vice versa ($30 to $10) and ($10 to $30) then the routine behaves normally. The first thing it does is to check the button and bmi to 1fbf if the button is pressed to return the value in $c4. This is clearly backwards and must be a BPL. puts left button in $26 right in $27 up in $28 down in $29 when the routine exits, it has loaded the accumulator with the value of one of the following memory addresses (which basically mimics the keyboard actions):
$c0 = c1 = A
$c1 = 95 = CTRL+U or right arrow
$c2 = da = Z
$c3 = 88 = CTRL+H or left arrow
$c4 = a0 = space
1F40: AD 61 C0 lda RDBTN0
1F43: 30 7A bmi $1fbf
1F45: AD 5A C0 lda CLRAN1
1F48: AD 62 C0 lda BUTN1
1F4B: 85 26 sta <GBASL
1F4D: AD 63 C0 lda RD63
1F50: 85 27 sta <GBASH
1F52: AD 5B C0 lda SETAN1
1F55: AD 62 C0 lda BUTN1
1F58: 85 28 sta <BASL
1F5A: AD 63 C0 lda RD63
1F5D: 85 29 sta <BASH
1F5F: A5 26 lda <GBASL
1F61: 05 27 ora $27
1F63: 85 2A sta $2a
1F65: A5 28 lda <BASL
1F67: 05 29 ora $29
1F69: 25 2A and $2a
1F6B: 10 0A bpl $1f77
1F6D: 24 FE bit $fe
1F6F: 10 03 bpl $1f74
1F71: 4C 8B 1F jmp $1f8b
1F74: 4C 96 1F jmp $1f96
1F77: 20 8B 1F jsr $1f8b
1F7A: F0 01 beq $1f7d
1F7C: 60 rts
1F7D: 20 96 1F jsr $1f96
1F80: F0 01 beq $1f83
1F82: 60 rts
1F83: A9 00 lda #$00
1F85: 85 80 sta $80
1F87: AD 00 C0 lda KBD / 80STOREOFF
1F8A: 60 rts
if 26 (left) is pressed, go to 1faf (load $c3)
1F8B: A5 26 lda <GBASL
1F8D: 30 20 bmi $1faf
if 27 (right) is pressed go to 1fb3 (load $c1)
1F8F: A5 27 lda <GBASH
1F91: 30 20 bmi $1fb3
1F93: A9 00 lda #$00
1F95: 60 rts
1F96: A5 28 lda <BASL
1F98: 30 1D bmi $1fb7
1F9A: A5 29 lda <BASH
1F9C: 30 1D bmi $1fbb
1F9E: A9 00 lda #$00
1FA0: 60 rts
1FA1: 08 php
1FA2: A0 00 ldy #$00
1FA4: 84 FE sty $fe
1FA6: 28 plp
1FA7: 60 rts
1FA8: 08 php
1FA9: A0 80 ldy #$80
1FAB: 84 FE sty $fe
1FAD: 28 plp
1FAE: 60 rts
load the value into A and set/clear the diagonal flag in $fe on the way out
1FAF: A5 C3 lda $c3
1FB1: D0 EE bne $1fa1 clear the diagonal flag
1FB3: A5 C1 lda $c1
1FB5: D0 EA bne $1fa1
1FB7: A5 C0 lda $c0
1FB9: D0 ED bne $1fa8 set the diagonal flag
1FBB: A5 C2 lda $c2
1FBD: D0 E9 bne $1fa8
1FBF: A5 C4 lda $c4
1FC1: 60 rts
So I after I flipped the bmi <-> bpl, the routine worked more normally, but diagonals weren't working so I had to flip the ora <-> and ($05 to $25) as well.
< 1F43: 30 7A bmi $1fbf
---
> 1F43: 10 7A bpl $1fbf
14c14
< 1F61: 05 27 ora $27
---
> 1F61: 25 27 and $27
17,19c17,19
< 1F67: 05 29 ora $29
< 1F69: 25 2A and $2a
< 1F6B: 10 0A bpl $1f77
---
> 1F67: 25 29 and $29
> 1F69: 05 2A ora $2a
> 1F6B: 30 0A bmi $1f77
35c35
< 1F8D: 30 20 bmi $1faf
---
> 1F8D: 10 20 bpl $1faf
37c37
< 1F91: 30 20 bmi $1fb3
---
> 1F91: 10 20 bpl $1fb3
41c41
< 1F98: 30 1D bmi $1fb7
---
> 1F98: 10 1D bpl $1fb7
43c43
< 1F9C: 30 1D bmi $1fbb
---
> 1F9C: 10 1D bpl $1fbb
I wonder if this code is a vestige of an early version of the joyport when it may have had active high buttons, or a copy protection? It's soooo much better with a joyport than the keyboard.
|
|
|
|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
I was trying to figure out how some of the keystrokes can be generated and noticed some very small and subtle discrepancies in the keytable: Somewhere in the copts and robbers code it was checking for a keycode of 0x9e and 0x9d which can only be generated by ctrl+shift+M = 0x9d and ctrl+shift+N = 0x9e so according the manual m will generate CD 8D DD 9D and the manual has the columns in different order of ctrl shift so to match the key_remap table it would be: cd dd 8d 9d -> (removing the high bit) 4d 5d 0d 1d { 0x4d,0x4d,0x0d,0x0d }, /* m M 24 */ N is CE 8E dE 9E and reordering ce de 8e 9e -> 4e 5e 0e 1e I don't have real hardware to test against, so ymmv. This is from the apple ii reference manual, is the 2 plus any different? static const uint8_t a2_key_remap[0x32][4] = { /* norm shft ctrl both */ { 0x33,0x23,0x33,0x23 }, /* 3 # 00 */ { 0x34,0x24,0x34,0x24 }, /* 4 $ 01 */ ... { 0x08,0x08,0x08,0x08 }, /* Left 1c */ { 0x15,0x15,0x15,0x15 }, /* Right 1d */ { 0x5a,0x5a,0x1a,0x1a }, /* z Z 1e */ { 0x58,0x58,0x18,0x18 }, /* x X 1f */ { 0x43,0x43,0x03,0x03 }, /* c C 20 */ { 0x56,0x56,0x16,0x16 }, /* v V 21 */ { 0x42,0x42,0x02,0x02 }, /* b B 22 */ { 0x4e,0x5e,0x0e,0x5e }, /* n N 23 */ { 0x4d,0x4d,0x0d,0x0d }, /* m M 24 */ Interestingly they didn't do that with CTRL+SHIFT+L and CTRL+SHIFT+O to generate the unique codes of 9C and 9F, just with CTRL+M and CTRL+N. Looking at the this, I wonder why they just didn't add some small modifications to this table so the apple 2 could type backslashes, both brackets and underscores directly from the keyboard with a CTRL+SHIFT. That would've been really useful as a bunch of codes can't be typed. $DB,DC, and DF are missing. CTRL+SHIFT could've given codes from E0 to FF. (I suppose they fixed all this with the 2e) Just as an experiment I modified the table so I could type underscore with a CTRL+SHIFT+L and backslash with CTRL+SHIFT+O and it seemed to work fine with PRINT "_\".
Last edited by Golden Child; 09/07/19 03:33 PM.
|
|
|
|
Joined: Mar 2001
Posts: 17,234 Likes: 260
Very Senior Member
|
Very Senior Member
Joined: Mar 2001
Posts: 17,234 Likes: 260 |
Thanks for the additional fixes. The II and II Plus are completely identical aside from the ROMs.
|
|
|
|
Joined: Feb 2014
Posts: 1,124 Likes: 193
Very Senior Member
|
Very Senior Member
Joined: Feb 2014
Posts: 1,124 Likes: 193 |
|
|
|
|
Joined: Apr 2010
Posts: 58
Member
|
Member
Joined: Apr 2010
Posts: 58 |
Regarding the key matrix, Apple used the off the shelf MOS MM5740 AAE, which was designed to work with or mimic a Teletype ASR 33 type keyboard : http://www.bitsavers.org/communicat...pewriter_Sets_Technical_Manual_Sep74.pdf at page 99 you can see the keymapping. Although custom decoding could be ordered for the MOS MM5740, I don't expect Apple would have wanted to pay for it.
|
|
|
1 members (Vas Crabb),
177
guests, and
0
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
Forums9
Topics9,328
Posts122,128
Members5,074
|
Most Online1,283 Dec 21st, 2022
|
|
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!
|
|
|
|