Jump to content
IGNORED

Something perhaps only I will find useful: a macro for automatedly pasting code into the MAME CC-40 Emulation


Recommended Posts

If any of you use Autohotkey, well, here is an AHK macro for pasting the clipboard into MAME CC-40 BASIC in an automated fashion (which observes relevant keystroke combinations for the emulation). 

 

Probably I am the only person on earth who finds this useful.  But in case anyone else does, here it is. 

 

Simply press INSERT and code contained on the clipboard will be typed into the CC-40. 

 

Like so:

 

 

 

 

Some minor error checking is observed (duplicate lines, lines without a number, out-of-order lines which may be indicative of incorrect numbering). 

 

Typing will terminate if the window is deselected.

 

#IfWinActive MAME: Compact Computer 40 [cc40]
{
Insert::
	lines:=[]
	prev:=0
	Loop, parse, clipboard,`n,`r ; split on LF, omit CR if present
		{
		content:=StrSplit(A_LoopField,A_Space,,2)
		num:=content[1]
		if (num="")    
			{
			continue
			}		
		else if num is not digit ; if no valid line number
			{
			mess:="No valid line number for line " A_Index ". in text. Line reads `n`n" Trim(A_Loopfield) "`n`nEnter anyway?"
			MsgBox, 4, , %mess%
			IfMsgBox No
				{
				return
				}
			continue
			}
		else if (lines[num]) ; if line number duplicated
			{
			mess:="Line number " num " used here:`n`n" num A_Space lines[num] "`n`nAlso found here:`n`n " num A_Space content[2] "`n`nEnter anyway?"
			MsgBox, 4, , %mess%
			ifMsgBox No
				{
				return
				}
			}
		else if (num<prev)
			{
			mess:="Line number " prev " precedes line number " num " as follows:`n`n" prev A_Space lines[prev] "`n" num A_Space content[2] "`n`nEnter anyway?"
			MsgBox, 4, , %mess%
			ifMsgBox No
				{
				return
				}			
			}
		lines[num]:=content[2]
		prev:=num
		}
	SetKeyDelay, 40,50 ; pre-press delay and press duration in ms
	Sleep, 300
	Loop, parse, clipboard,,`r
		{
		IfWinNotActive, ahk_exe Mame64.exe
			{
			return
			}
		switch A_LoopField
			{			
			case Chr(34): Send +2
			case "!": Send +1
			case "(": Send +8
			case ")": Send +9
			case "'": Send +0
			case "+": Send {NumpadAdd}
			case "?": Send +{=}
			case "*": Send {NumpadMult}
			case "/": Send {NumpadDiv}
			case Chr(10): 
				{
				Send {Enter}
				Sleep, 750 ; newline delay in ms
				}
			default: Send %A_Loopfield%
			}
		}
	Send {Enter} ; optionally, always enter final line even when newline absent
return
}

 

 

  • Like 4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...